From 858b34a0652ce0a819302e69d935a3590b0f0df9 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 28 May 2012 10:24:23 +0200 Subject: [PATCH] Fix some quality flaws --- .../core/sensors/ViolationsDecorator.java | 12 +++--------- .../review/workflow/review/DefaultReview.java | 2 +- .../sonar/server/plugins/ClassLoaderUtils.java | 16 ++++++++++------ .../connectors/HttpClient3Connector.java | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ViolationsDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ViolationsDecorator.java index 2f16051638b..a73cae6fd16 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ViolationsDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ViolationsDecorator.java @@ -42,10 +42,6 @@ public class ViolationsDecorator implements Decorator { return true; } - private boolean shouldDecorateResource(Resource resource) { - return true; - } - @DependedUpon public List generatesViolationsMetrics() { return Arrays.asList(CoreMetrics.VIOLATIONS, @@ -57,11 +53,9 @@ public class ViolationsDecorator implements Decorator { } public void decorate(Resource resource, DecoratorContext context) { - if (shouldDecorateResource(resource)) { - computeTotalViolations(context); - computeViolationsPerSeverities(context); - computeViolationsPerRules(context); - } + computeTotalViolations(context); + computeViolationsPerSeverities(context); + computeViolationsPerRules(context); } private void computeTotalViolations(DecoratorContext context) { diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultReview.java b/sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultReview.java index 2eda5a5dc1c..68989f0921e 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultReview.java +++ b/sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultReview.java @@ -172,7 +172,7 @@ public final class DefaultReview implements MutableReview { return this; } - public DefaultReview setPropertiesAsString(String s) { + public DefaultReview setPropertiesAsString(@Nullable String s) { this.properties = (s == null ? null : KeyValueFormat.parse(s)); return this; } diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/ClassLoaderUtils.java b/sonar-server/src/main/java/org/sonar/server/plugins/ClassLoaderUtils.java index 6bb90f623d4..f54f3947ffb 100644 --- a/sonar-server/src/main/java/org/sonar/server/plugins/ClassLoaderUtils.java +++ b/sonar-server/src/main/java/org/sonar/server/plugins/ClassLoaderUtils.java @@ -126,12 +126,16 @@ public final class ClassLoaderUtils { } catch (Exception e) { throw Throwables.propagate(e); } finally { - if (jar != null) { - try { - jar.close(); - } catch (Exception e) { - LoggerFactory.getLogger(ClassLoaderUtils.class).error("Fail to close JAR file: " + jarPath, e); - } + closeJar(jar, jarPath); + } + } + + private static void closeJar(JarFile jar, String jarPath) { + if (jar != null) { + try { + jar.close(); + } catch (Exception e) { + LoggerFactory.getLogger(ClassLoaderUtils.class).error("Fail to close JAR file: " + jarPath, e); } } } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java index dfd615778cb..cd4274e306b 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java @@ -180,7 +180,7 @@ public class HttpClient3Connector extends Connector { try { reader.close(); } catch (Exception e) { - throw new RuntimeException("Fail to close HTTP stream", e); + // wsclient does not have logging ability -> silently ignore } } } -- 2.39.5