diff options
author | Sébastien Lesaint <sns-seb@users.noreply.github.com> | 2015-06-19 16:02:40 +0200 |
---|---|---|
committer | Sébastien Lesaint <sns-seb@users.noreply.github.com> | 2015-06-19 16:02:40 +0200 |
commit | f03ce16fbade17fabd9e44726de6bf99f933c7a9 (patch) | |
tree | ad83b501b348956c5cc386d04449819bae4d51af | |
parent | d7e2e31271ec68436da21e077261d1e367f56809 (diff) | |
parent | 6f7dcf0f6ad046940c37a14041e2ddd02c457776 (diff) | |
download | sonarqube-f03ce16fbade17fabd9e44726de6bf99f933c7a9.tar.gz sonarqube-f03ce16fbade17fabd9e44726de6bf99f933c7a9.zip |
Merge pull request #366 from gliptak/warnings1
Cleanup warnings
27 files changed, 117 insertions, 104 deletions
diff --git a/server/sonar-process/src/test/java/org/sonar/process/LogbackHelperTest.java b/server/sonar-process/src/test/java/org/sonar/process/LogbackHelperTest.java index e4cad8faea8..1e2a9756224 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/LogbackHelperTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/LogbackHelperTest.java @@ -81,7 +81,7 @@ public class LogbackHelperTest { @Test public void newConsoleAppender() { LoggerContext ctx = sut.getRootContext(); - ConsoleAppender appender = sut.newConsoleAppender(ctx, "MY_APPENDER", "%msg%n"); + ConsoleAppender<?> appender = sut.newConsoleAppender(ctx, "MY_APPENDER", "%msg%n"); assertThat(appender.getName()).isEqualTo("MY_APPENDER"); assertThat(appender.getContext()).isSameAs(ctx); diff --git a/server/sonar-search/src/main/java/org/sonar/search/SearchLogging.java b/server/sonar-search/src/main/java/org/sonar/search/SearchLogging.java index 2c2d45ad39b..bb031f8407f 100644 --- a/server/sonar-search/src/main/java/org/sonar/search/SearchLogging.java +++ b/server/sonar-search/src/main/java/org/sonar/search/SearchLogging.java @@ -22,7 +22,9 @@ package org.sonar.search; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.ConsoleAppender; + import org.sonar.process.LogbackHelper; public class SearchLogging { @@ -35,7 +37,7 @@ public class SearchLogging { LoggerContext ctx = helper.getRootContext(); ctx.reset(); - ConsoleAppender consoleAppender = helper.newConsoleAppender(ctx, "CONSOLE", LOG_FORMAT); + ConsoleAppender<ILoggingEvent> consoleAppender = helper.newConsoleAppender(ctx, "CONSOLE", LOG_FORMAT); Logger rootLogger = helper.configureLogger(ctx, Logger.ROOT_LOGGER_NAME, Level.INFO); rootLogger.addAppender(consoleAppender); return ctx; diff --git a/server/sonar-server/src/main/java/org/sonar/server/app/WebLogging.java b/server/sonar-server/src/main/java/org/sonar/server/app/WebLogging.java index a434e44159c..2e1e88c499a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/app/WebLogging.java +++ b/server/sonar-server/src/main/java/org/sonar/server/app/WebLogging.java @@ -22,7 +22,9 @@ package org.sonar.server.app; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.ConsoleAppender; + import org.slf4j.bridge.SLF4JBridgeHandler; import org.sonar.api.utils.MessageException; import org.sonar.process.LogbackHelper; @@ -56,7 +58,7 @@ class WebLogging { } private void configureAppender(LoggerContext ctx) { - ConsoleAppender consoleAppender = helper.newConsoleAppender(ctx, "CONSOLE", LOG_FORMAT); + ConsoleAppender<ILoggingEvent> consoleAppender = helper.newConsoleAppender(ctx, "CONSOLE", LOG_FORMAT); ctx.getLogger(Logger.ROOT_LOGGER_NAME).addAppender(consoleAppender); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/BaseDao.java b/server/sonar-server/src/main/java/org/sonar/server/db/BaseDao.java index e0875201856..83b46ae6209 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/BaseDao.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/BaseDao.java @@ -215,7 +215,7 @@ public abstract class BaseDao<MAPPER, DTO extends Dto<KEY>, KEY extends Serializ item.setUpdatedAt(now); doUpdate(session, item); if (hasIndex()) { - session.enqueue(new UpsertDto(getIndexType(), item)); + session.enqueue(new UpsertDto<DTO>(getIndexType(), item)); } } catch (Exception e) { throw new IllegalStateException("Fail to update item in db: " + item, e); diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyBulkRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyBulkRequestBuilder.java index acb87886f66..e3ca7507fa5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyBulkRequestBuilder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyBulkRequestBuilder.java @@ -82,7 +82,7 @@ public class ProxyBulkRequestBuilder extends BulkRequestBuilder { message.append("Bulk["); Multiset<BulkRequestKey> groupedRequests = LinkedHashMultiset.create(); for (int i = 0; i < request.requests().size(); i++) { - ActionRequest item = request.requests().get(i); + ActionRequest<?> item = request.requests().get(i); String requestType, index, docType; if (item instanceof IndexRequest) { IndexRequest request = (IndexRequest) item; diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationIndexer.java index 0a8c3efd3f4..5965b32a07b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationIndexer.java @@ -95,13 +95,12 @@ public class IssueAuthorizationIndexer extends BaseIndexer { } private ActionRequest newUpdateRequest(IssueAuthorizationDao.Dto dto) { - ActionRequest request; Map<String, Object> doc = ImmutableMap.of( IssueIndexDefinition.FIELD_AUTHORIZATION_PROJECT_UUID, dto.getProjectUuid(), IssueIndexDefinition.FIELD_AUTHORIZATION_GROUPS, dto.getGroups(), IssueIndexDefinition.FIELD_AUTHORIZATION_USERS, dto.getUsers(), IssueIndexDefinition.FIELD_AUTHORIZATION_UPDATED_AT, new Date(dto.getUpdatedAt())); - request = new UpdateRequest(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_AUTHORIZATION, dto.getProjectUuid()) + ActionRequest<?> request = new UpdateRequest(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_AUTHORIZATION, dto.getProjectUuid()) .routing(dto.getProjectUuid()) .doc(doc) .upsert(doc); diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/Views.java b/server/sonar-server/src/main/java/org/sonar/server/ui/Views.java index e70b00c8041..4ad9a25d040 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ui/Views.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ui/Views.java @@ -118,7 +118,7 @@ public class Views { return Lists.newArrayList(widgets); } - protected static boolean accept(ViewProxy proxy, + protected static boolean accept(ViewProxy<?> proxy, @Nullable String section, @Nullable String resourceScope, @Nullable String resourceQualifier, @Nullable String resourceLanguage, @Nullable String[] availableMeasures) { return acceptNavigationSection(proxy, section) && acceptResourceScope(proxy, resourceScope) @@ -127,23 +127,23 @@ public class Views { && acceptAvailableMeasures(proxy, availableMeasures); } - protected static boolean acceptResourceLanguage(ViewProxy proxy, @Nullable String resourceLanguage) { + protected static boolean acceptResourceLanguage(ViewProxy<?> proxy, @Nullable String resourceLanguage) { return resourceLanguage == null || ArrayUtils.isEmpty(proxy.getResourceLanguages()) || ArrayUtils.contains(proxy.getResourceLanguages(), resourceLanguage); } - protected static boolean acceptResourceScope(ViewProxy proxy, @Nullable String resourceScope) { + protected static boolean acceptResourceScope(ViewProxy<?> proxy, @Nullable String resourceScope) { return resourceScope == null || ArrayUtils.isEmpty(proxy.getResourceScopes()) || ArrayUtils.contains(proxy.getResourceScopes(), resourceScope); } - protected static boolean acceptResourceQualifier(ViewProxy proxy, @Nullable String resourceQualifier) { + protected static boolean acceptResourceQualifier(ViewProxy<?> proxy, @Nullable String resourceQualifier) { return resourceQualifier == null || ArrayUtils.isEmpty(proxy.getResourceQualifiers()) || ArrayUtils.contains(proxy.getResourceQualifiers(), resourceQualifier); } - protected static boolean acceptNavigationSection(ViewProxy proxy, @Nullable String section) { + protected static boolean acceptNavigationSection(ViewProxy<?> proxy, @Nullable String section) { return proxy.isWidget() || section == null || ArrayUtils.contains(proxy.getSections(), section); } - protected static boolean acceptAvailableMeasures(ViewProxy proxy, @Nullable String[] availableMeasures) { + protected static boolean acceptAvailableMeasures(ViewProxy<?> proxy, @Nullable String[] availableMeasures) { return availableMeasures == null || proxy.acceptsAvailableMeasures(availableMeasures); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/app/ProgrammaticLogbackValveTest.java b/server/sonar-server/src/test/java/org/sonar/server/app/ProgrammaticLogbackValveTest.java index ee436f7f9f3..c447639c601 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/app/ProgrammaticLogbackValveTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/app/ProgrammaticLogbackValveTest.java @@ -19,7 +19,9 @@ */ package org.sonar.server.app; +import ch.qos.logback.access.spi.IAccessEvent; import ch.qos.logback.core.ConsoleAppender; + import org.apache.catalina.Container; import org.junit.Test; import org.sonar.process.LogbackHelper; @@ -34,7 +36,7 @@ public class ProgrammaticLogbackValveTest { ProgrammaticLogbackValve valve = new ProgrammaticLogbackValve(); valve.setContainer(mock(Container.class)); LogbackHelper helper = new LogbackHelper(); - ConsoleAppender appender = helper.newConsoleAppender(valve, "CONSOLE", "combined"); + ConsoleAppender<IAccessEvent> appender = helper.newConsoleAppender(valve, "CONSOLE", "combined"); valve.addAppender(appender); valve.start(); assertThat(valve.isStarted()).isTrue(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java b/server/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java index 2895462beed..916a083e7b4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java @@ -66,7 +66,7 @@ public class ViewProxyTest { } View view = new MyView(); - ViewProxy proxy = new ViewProxy<>(view, userSession); + ViewProxy<?> proxy = new ViewProxy<>(view, userSession); assertThat(proxy.getTarget()).isEqualTo(view); assertThat(proxy.getSections()).isEqualTo(new String[] {NavigationSection.RESOURCE}); @@ -82,7 +82,7 @@ public class ViewProxyTest { } } View view = new MyView(); - ViewProxy proxy = new ViewProxy<>(view, userSession); + ViewProxy<?> proxy = new ViewProxy<>(view, userSession); assertThat(proxy.getTarget()).isEqualTo(view); assertThat(proxy.getSections()).isEqualTo(new String[] {NavigationSection.HOME}); @@ -98,7 +98,7 @@ public class ViewProxyTest { } } - ViewProxy proxy = new ViewProxy<>(new MyView(), userSession); + ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession); assertThat(proxy.isDefaultTab()).isTrue(); assertThat(proxy.getDefaultTabForMetrics()).isEmpty(); @@ -111,7 +111,7 @@ public class ViewProxyTest { super("fake"); } } - ViewProxy proxy = new ViewProxy<>(new MyView(), userSession); + ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession); assertThat(proxy.isDefaultTab()).isFalse(); assertThat(proxy.getDefaultTabForMetrics()).isEmpty(); @@ -125,7 +125,7 @@ public class ViewProxyTest { super("fake"); } } - ViewProxy proxy = new ViewProxy<>(new MyView(), userSession); + ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession); assertThat(proxy.isDefaultTab()).isFalse(); assertThat(proxy.getDefaultTabForMetrics()).isEqualTo(new String[] {"ncloc", "coverage"}); @@ -199,7 +199,7 @@ public class ViewProxyTest { super("fake"); } } - ViewProxy proxy = new ViewProxy<>(new MyView(), userSession); + ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession); assertThat(proxy.acceptsAvailableMeasures(new String[] {"lines", "ncloc", "coverage"})).isTrue(); } @@ -212,7 +212,7 @@ public class ViewProxyTest { super("fake"); } } - ViewProxy proxy = new ViewProxy<>(new MyView(), userSession); + ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession); assertThat(proxy.acceptsAvailableMeasures(new String[] {"lines", "ncloc", "coverage"})).isTrue(); assertThat(proxy.acceptsAvailableMeasures(new String[] {"lines", "coverage"})).isFalse(); @@ -226,7 +226,7 @@ public class ViewProxyTest { super("fake"); } } - ViewProxy proxy = new ViewProxy<>(new MyView(), userSession); + ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession); assertThat(proxy.acceptsAvailableMeasures(new String[] {"lines", "coverage"})).isTrue(); assertThat(proxy.acceptsAvailableMeasures(new String[] {"complexity", "coverage"})).isFalse(); @@ -240,7 +240,7 @@ public class ViewProxyTest { super("fake"); } } - ViewProxy proxy = new ViewProxy<>(new MyView(), userSession); + ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession); // ok, mandatory measures and 1 needed measure assertThat(proxy.acceptsAvailableMeasures(new String[] {"lines", "ncloc", "coverage", "duplications"})).isTrue(); @@ -260,7 +260,7 @@ public class ViewProxyTest { } } - ViewProxy proxy = new ViewProxy<>(new MyView(), userSession); + ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession); assertThat(proxy.isUserAuthorized()).isTrue(); } @@ -276,7 +276,7 @@ public class ViewProxyTest { } } - ViewProxy proxy = new ViewProxy<>(new MyView(), userSession); + ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession); userSession.setGlobalPermissions("palap"); assertThat(proxy.isUserAuthorized()).isTrue(); @@ -293,7 +293,7 @@ public class ViewProxyTest { } } - ViewProxy proxy = new ViewProxy<>(new MyView(), userSession); + ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession); userSession.setGlobalPermissions("pilip"); assertThat(proxy.isUserAuthorized()).isFalse(); @@ -309,7 +309,7 @@ public class ViewProxyTest { } } - ViewProxy proxy = new ViewProxy<>(new MyView(), userSession); + ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession); assertThat(proxy.isUserAuthorized(newProjectDto("abcd"))).isTrue(); } @@ -325,7 +325,7 @@ public class ViewProxyTest { } } - ViewProxy proxy = new ViewProxy<>(new MyView(), userSession); + ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession); userSession.addProjectUuidPermissions("palap", "abcd"); assertThat(proxy.isUserAuthorized(newProjectDto("abcd"))).isTrue(); @@ -342,7 +342,7 @@ public class ViewProxyTest { } } - ViewProxy proxy = new ViewProxy<>(new MyView(), userSession); + ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession); userSession.addProjectUuidPermissions("pilip", "abcd"); assertThat(proxy.isUserAuthorized(newProjectDto("abcd"))).isFalse(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/ui/ViewsTest.java b/server/sonar-server/src/test/java/org/sonar/server/ui/ViewsTest.java index 72904514454..cfc81a65936 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/ui/ViewsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/ui/ViewsTest.java @@ -96,7 +96,7 @@ public class ViewsTest { @Test public void should_accept_navigation_section() { - ViewProxy proxy = mock(ViewProxy.class); + ViewProxy<?> proxy = mock(ViewProxy.class); when(proxy.getSections()).thenReturn(new String[] {NavigationSection.RESOURCE}); when(proxy.isWidget()).thenReturn(false); @@ -109,7 +109,7 @@ public class ViewsTest { @Test public void should_accept_available_measures() { - ViewProxy proxy = mock(ViewProxy.class); + ViewProxy<?> proxy = mock(ViewProxy.class); when(proxy.acceptsAvailableMeasures(new String[] {"lines"})).thenReturn(true); when(proxy.acceptsAvailableMeasures(new String[] {"ncloc"})).thenReturn(false); @@ -124,7 +124,7 @@ public class ViewsTest { @Test public void should_not_check_navigation_section_on_widgets() { - ViewProxy proxy = mock(ViewProxy.class); + ViewProxy<?> proxy = mock(ViewProxy.class); when(proxy.isWidget()).thenReturn(true); assertThat(Views.acceptNavigationSection(proxy, NavigationSection.RESOURCE)).isEqualTo(true); @@ -136,7 +136,7 @@ public class ViewsTest { @Test public void should_check_resource_language() { - ViewProxy proxy = mock(ViewProxy.class); + ViewProxy<?> proxy = mock(ViewProxy.class); assertThat(Views.acceptResourceLanguage(proxy, Java.KEY)).isEqualTo(true); when(proxy.getResourceLanguages()).thenReturn(new String[] {"foo"}); @@ -146,7 +146,7 @@ public class ViewsTest { @Test public void should_check_resource_scope() { - ViewProxy proxy = mock(ViewProxy.class); + ViewProxy<?> proxy = mock(ViewProxy.class); assertThat(Views.acceptResourceScope(proxy, Scopes.FILE)).isEqualTo(true); when(proxy.getResourceScopes()).thenReturn(new String[] {Scopes.PROJECT, Scopes.FILE}); @@ -156,7 +156,7 @@ public class ViewsTest { @Test public void should_check_resource_qualifier() { - ViewProxy proxy = mock(ViewProxy.class); + ViewProxy<?> proxy = mock(ViewProxy.class); assertThat(Views.acceptResourceQualifier(proxy, Scopes.FILE)).isEqualTo(true); when(proxy.getResourceQualifiers()).thenReturn(new String[] {Qualifiers.CLASS, Qualifiers.FILE}); diff --git a/sonar-application/src/main/java/org/sonar/application/AppLogging.java b/sonar-application/src/main/java/org/sonar/application/AppLogging.java index bec5548a4bd..7787e5ea8a3 100644 --- a/sonar-application/src/main/java/org/sonar/application/AppLogging.java +++ b/sonar-application/src/main/java/org/sonar/application/AppLogging.java @@ -23,9 +23,11 @@ import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.encoder.PatternLayoutEncoder; +import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.Appender; import ch.qos.logback.core.ConsoleAppender; import ch.qos.logback.core.FileAppender; + import org.slf4j.LoggerFactory; import org.sonar.process.LogbackHelper; import org.sonar.process.Props; @@ -62,14 +64,14 @@ class AppLogging { */ private static void copyGobblerToConsole() { Logger consoleLogger = (Logger) LoggerFactory.getLogger(CONSOLE_LOGGER); - Appender consoleAppender = consoleLogger.getAppender(CONSOLE_APPENDER); + Appender<ILoggingEvent> consoleAppender = consoleLogger.getAppender(CONSOLE_APPENDER); Logger gobblerLogger = (Logger) LoggerFactory.getLogger(GOBBLER_LOGGER); gobblerLogger.addAppender(consoleAppender); } private void configureConsole(LoggerContext loggerContext) { - ConsoleAppender consoleAppender = helper.newConsoleAppender(loggerContext, CONSOLE_APPENDER, "%msg%n"); + ConsoleAppender<ILoggingEvent> consoleAppender = helper.newConsoleAppender(loggerContext, CONSOLE_APPENDER, "%msg%n"); Logger consoleLogger = loggerContext.getLogger(CONSOLE_LOGGER); consoleLogger.setAdditive(false); consoleLogger.addAppender(consoleAppender); @@ -78,7 +80,7 @@ class AppLogging { private void configureGobbler(Props props, LoggerContext ctx) { // configure appender LogbackHelper.RollingPolicy rollingPolicy = helper.createRollingPolicy(ctx, props, "sonar"); - FileAppender fileAppender = rollingPolicy.createAppender(GOBBLER_APPENDER); + FileAppender<ILoggingEvent> fileAppender = rollingPolicy.createAppender(GOBBLER_APPENDER); fileAppender.setContext(ctx); PatternLayoutEncoder fileEncoder = new PatternLayoutEncoder(); fileEncoder.setContext(ctx); @@ -94,7 +96,7 @@ class AppLogging { } private void configureRoot(LoggerContext loggerContext) { - ConsoleAppender consoleAppender = helper.newConsoleAppender(loggerContext, "ROOT_CONSOLE", APP_PATTERN); + ConsoleAppender<ILoggingEvent> consoleAppender = helper.newConsoleAppender(loggerContext, "ROOT_CONSOLE", APP_PATTERN); Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); rootLogger.setLevel(Level.INFO); rootLogger.addAppender(consoleAppender); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java index 1254f67e315..6bef676b656 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java @@ -116,7 +116,7 @@ public class ProjectFileSystemAdapter implements ProjectFileSystem { @Override public File getSonarWorkingDirectory() { - return target.workingDir(); + return target.workDir(); } @Override @@ -165,7 +165,7 @@ public class ProjectFileSystemAdapter implements ProjectFileSystem { @Override public File writeToWorkingDirectory(String content, String fileName) throws IOException { - File file = new File(target.workingDir(), fileName); + File file = new File(target.workDir(), fileName); FileUtils.writeStringToFile(file, content, CharEncoding.UTF_8); return file; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java b/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java index d0f6f4f6fcc..57197abc0a1 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java +++ b/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java @@ -76,7 +76,7 @@ public class DefaultSensorContext implements SensorContext { @Override public <G extends Serializable> NewMeasure<G> newMeasure() { - return new DefaultMeasure(sensorStorage); + return new DefaultMeasure<G>(sensorStorage); } @Override diff --git a/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java b/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java index 208dc809210..b97c94f492b 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java +++ b/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java @@ -102,7 +102,7 @@ public class DefaultSensorStorage implements SensorStorage { @Override public void store(Measure newMeasure) { - DefaultMeasure measure = (DefaultMeasure) newMeasure; + DefaultMeasure<?> measure = (DefaultMeasure<?>) newMeasure; org.sonar.api.measures.Metric m = findMetricOrFail(measure.metric().key()); org.sonar.api.measures.Measure measureToSave = new org.sonar.api.measures.Measure(m); setValueAccordingToMetricType(newMeasure, m, measureToSave); diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java index e1c0eb4c65e..4a5e04b4a8e 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java @@ -123,7 +123,7 @@ public class DefaultModuleFileSystemTest { new Project("foo"), settings, fileIndexer, initializer, componentIndexer); assertThat(fs.baseDir().getCanonicalPath()).isEqualTo(basedir.getCanonicalPath()); - assertThat(fs.workingDir().getCanonicalPath()).isEqualTo(workingDir.getCanonicalPath()); + assertThat(fs.workDir().getCanonicalPath()).isEqualTo(workingDir.getCanonicalPath()); assertThat(fs.buildDir().getCanonicalPath()).isEqualTo(buildDir.getCanonicalPath()); assertThat(fs.sourceDirs()).hasSize(2); assertThat(fs.testDirs()).hasSize(1); diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java index 67e450093a2..c75ad09cc0b 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java @@ -63,7 +63,7 @@ public class ProjectFileSystemAdapterTest { public void should_create_default_build_dir() throws IOException { File workingDir = temp.newFile("work"); DefaultModuleFileSystem target = mock(DefaultModuleFileSystem.class); - when(target.workingDir()).thenReturn(workingDir); + when(target.workDir()).thenReturn(workingDir); ProjectFileSystemAdapter adapter = new ProjectFileSystemAdapter(target, new Project("my-project")); File buildDir = adapter.getBuildDir(); diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/BatchSession.java b/sonar-core/src/main/java/org/sonar/core/persistence/BatchSession.java index bcc1b481a18..f4603ade974 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/BatchSession.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/BatchSession.java @@ -40,11 +40,11 @@ public class BatchSession extends DbSession { private final int batchSize; private int count = 0; - BatchSession(WorkQueue queue, SqlSession session) { + BatchSession(WorkQueue<?> queue, SqlSession session) { this(queue, session, MAX_BATCH_SIZE); } - BatchSession(WorkQueue queue, SqlSession session, int batchSize) { + BatchSession(WorkQueue<?> queue, SqlSession session, int batchSize) { super(queue, session); this.batchSize = batchSize; } diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java b/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java index 17764552b20..23f00843f34 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java @@ -64,7 +64,6 @@ public final class DaoUtils { // only static stuff } - @SuppressWarnings("unchecked") public static List<Class> getDaoClasses() { return ImmutableList.<Class>of( ActionPlanDao.class, diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java index 4c7e567f7b5..d8234e01910 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java @@ -148,9 +148,9 @@ public class MyBatis { private SqlSessionFactory sessionFactory; // TODO this queue should directly be an IndexQueue. Pending move of persistence to sonar-server - private WorkQueue queue; + private WorkQueue<?> queue; - public MyBatis(Database database, Logback logback, WorkQueue queue) { + public MyBatis(Database database, Logback logback, WorkQueue<?> queue) { this.database = database; this.logback = logback; this.queue = queue; diff --git a/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java b/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java index d6a2a258a75..c66a963ba85 100644 --- a/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java +++ b/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java @@ -199,7 +199,7 @@ public class ComponentContainer { private String getName(Object extension) { if (extension instanceof Class) { - return ((Class) extension).getName(); + return ((Class<?>) extension).getName(); } return getName(extension.getClass()); } @@ -208,7 +208,7 @@ public class ComponentContainer { propertyDefinitions.addComponent(extension, pluginInfo != null ? pluginInfo.getName() : ""); } - public ComponentContainer addPicoAdapter(ComponentAdapter adapter) { + public ComponentContainer addPicoAdapter(ComponentAdapter<?> adapter) { pico.addAdapter(adapter); return this; } diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/BatchSessionTest.java b/sonar-core/src/test/java/org/sonar/core/persistence/BatchSessionTest.java index d8ef766f979..71f8c6a7e66 100644 --- a/sonar-core/src/test/java/org/sonar/core/persistence/BatchSessionTest.java +++ b/sonar-core/src/test/java/org/sonar/core/persistence/BatchSessionTest.java @@ -30,7 +30,7 @@ public class BatchSessionTest { @Test public void shouldCommitWhenReachingBatchSize() { SqlSession mybatisSession = mock(SqlSession.class); - WorkQueue queue = mock(WorkQueue.class); + WorkQueue<?> queue = mock(WorkQueue.class); BatchSession session = new BatchSession(queue, mybatisSession, 10); for (int i = 0; i < 9; i++) { @@ -41,12 +41,13 @@ public class BatchSessionTest { } session.insert("id9"); verify(mybatisSession).commit(); + session.close(); } @Test public void shouldCommitWhenReachingBatchSizeWithoutCommits() { SqlSession mybatisSession = mock(SqlSession.class); - WorkQueue queue = mock(WorkQueue.class); + WorkQueue<?> queue = mock(WorkQueue.class); BatchSession session = new BatchSession(queue, mybatisSession, 10); ClusterAction action = new ClusterAction() { @@ -63,17 +64,19 @@ public class BatchSessionTest { } session.enqueue(action); verify(mybatisSession).commit(); + session.close(); } @Test public void shouldResetCounterAfterCommit() { SqlSession mybatisSession = mock(SqlSession.class); - WorkQueue queue = mock(WorkQueue.class); + WorkQueue<?> queue = mock(WorkQueue.class); BatchSession session = new BatchSession(queue, mybatisSession, 10); for (int i = 0; i < 35; i++) { session.insert("id" + i); } verify(mybatisSession, times(3)).commit(); + session.close(); } } diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/MyBatisTest.java b/sonar-core/src/test/java/org/sonar/core/persistence/MyBatisTest.java index 26e56f19347..706e1523149 100644 --- a/sonar-core/src/test/java/org/sonar/core/persistence/MyBatisTest.java +++ b/sonar-core/src/test/java/org/sonar/core/persistence/MyBatisTest.java @@ -36,7 +36,7 @@ import static org.mockito.Mockito.mock; public class MyBatisTest { private static H2Database database; private Logback logback = mock(Logback.class); - private WorkQueue queue = mock(WorkQueue.class); + private WorkQueue<?> queue = mock(WorkQueue.class); @BeforeClass public static void start() { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasure.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasure.java index e798ce64fde..f6cccb2f2e7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/measure/internal/DefaultMeasure.java @@ -136,7 +136,7 @@ public class DefaultMeasure<G extends Serializable> extends DefaultStorable impl if (obj.getClass() != getClass()) { return false; } - DefaultMeasure rhs = (DefaultMeasure) obj; + DefaultMeasure<?> rhs = (DefaultMeasure<?>) obj; return new EqualsBuilder() .append(file, rhs.file) .append(metric, rhs.metric) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java index 3d535d401b4..1f3c4aa4240 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java @@ -170,7 +170,7 @@ public class Measure<G extends Serializable> implements Serializable { * @param mode the mode * @return the measure object instance */ - public Measure setPersistenceMode(@Nullable PersistenceMode mode) { + public Measure<G> setPersistenceMode(@Nullable PersistenceMode mode) { if (mode == null) { this.persistenceMode = PersistenceMode.FULL; } else { @@ -182,7 +182,7 @@ public class Measure<G extends Serializable> implements Serializable { /** * @return return the measures underlying metric */ - public Metric getMetric() { + public Metric<G> getMetric() { return metric; } @@ -196,7 +196,7 @@ public class Measure<G extends Serializable> implements Serializable { * @param metric the metric * @return the measure object instance */ - public Measure setMetric(Metric metric) { + public Measure<G> setMetric(Metric<G> metric) { this.metric = metric; this.metricKey = metric.getKey(); return this; @@ -229,7 +229,7 @@ public class Measure<G extends Serializable> implements Serializable { * @param date the date * @return the measure object instance */ - public Measure setDate(Date date) { + public Measure<G> setDate(Date date) { this.date = date; return this; } @@ -289,14 +289,14 @@ public class Measure<G extends Serializable> implements Serializable { * @param v the measure value * @return the measure object instance */ - public Measure setValue(@Nullable Double v) { + public Measure<G> setValue(@Nullable Double v) { return setValue(v, DEFAULT_PRECISION); } /** * For internal use */ - public Measure setRawValue(@Nullable Double v) { + public Measure<G> setRawValue(@Nullable Double v) { this.value = v; return this; } @@ -307,7 +307,7 @@ public class Measure<G extends Serializable> implements Serializable { * @param i the value * @return the measure object instance */ - public Measure setIntValue(Integer i) { + public Measure<G> setIntValue(Integer i) { if (i == null) { this.value = null; } else { @@ -323,7 +323,7 @@ public class Measure<G extends Serializable> implements Serializable { * @param precision the measure value precision * @return the measure object instance */ - public Measure setValue(@Nullable Double v, int precision) { + public Measure<G> setValue(@Nullable Double v, int precision) { if (v != null) { if (Double.isNaN(v)) { throw new IllegalArgumentException("Measure value can not be NaN"); @@ -354,7 +354,7 @@ public class Measure<G extends Serializable> implements Serializable { * @param s the data * @return the measure object instance */ - public Measure setData(String s) { + public Measure<G> setData(String s) { this.data = s; return this; } @@ -365,7 +365,7 @@ public class Measure<G extends Serializable> implements Serializable { * @param level the alert level * @return the measure object instance */ - public Measure setData(Metric.Level level) { + public Measure<G> setData(Metric.Level level) { if (level == null) { this.data = null; } else { @@ -377,7 +377,7 @@ public class Measure<G extends Serializable> implements Serializable { /** * @since 2.7 */ - public Measure unsetData() { + public Measure<G> unsetData() { this.data = null; return this; } @@ -395,7 +395,7 @@ public class Measure<G extends Serializable> implements Serializable { * @param description the description * @return the measure object instance */ - public Measure setDescription(String description) { + public Measure<G> setDescription(String description) { this.description = description; return this; } @@ -413,7 +413,7 @@ public class Measure<G extends Serializable> implements Serializable { * @param status the status * @return the measure object instance */ - public Measure setAlertStatus(@Nullable Metric.Level status) { + public Measure<G> setAlertStatus(@Nullable Metric.Level status) { this.alertStatus = status; return this; } @@ -431,7 +431,7 @@ public class Measure<G extends Serializable> implements Serializable { * @param alertText the text * @return the measure object instance */ - public Measure setAlertText(@Nullable String alertText) { + public Measure<G> setAlertText(@Nullable String alertText) { this.alertText = alertText; return this; } @@ -453,7 +453,7 @@ public class Measure<G extends Serializable> implements Serializable { * @return the measure object instance */ @Deprecated - public Measure setTendency(@Nullable Integer tendency) { + public Measure<G> setTendency(@Nullable Integer tendency) { return this; } @@ -462,7 +462,7 @@ public class Measure<G extends Serializable> implements Serializable { * @deprecated since 4.4 not used */ @Deprecated - public Measure setId(Long id) { + public Measure<G> setId(Long id) { return this; } @@ -479,7 +479,7 @@ public class Measure<G extends Serializable> implements Serializable { * * @since 2.5 */ - public Measure setVariation1(@Nullable Double d) { + public Measure<G> setVariation1(@Nullable Double d) { this.variation1 = d; return this; } @@ -497,7 +497,7 @@ public class Measure<G extends Serializable> implements Serializable { * * @since 2.5 */ - public Measure setVariation2(@Nullable Double d) { + public Measure<G> setVariation2(@Nullable Double d) { this.variation2 = d; return this; } @@ -515,7 +515,7 @@ public class Measure<G extends Serializable> implements Serializable { * * @since 2.5 */ - public Measure setVariation3(@Nullable Double d) { + public Measure<G> setVariation3(@Nullable Double d) { this.variation3 = d; return this; } @@ -533,7 +533,7 @@ public class Measure<G extends Serializable> implements Serializable { * * @since 2.5 */ - public Measure setVariation4(@Nullable Double d) { + public Measure<G> setVariation4(@Nullable Double d) { this.variation4 = d; return this; } @@ -551,7 +551,7 @@ public class Measure<G extends Serializable> implements Serializable { * * @since 2.5 */ - public Measure setVariation5(@Nullable Double d) { + public Measure<G> setVariation5(@Nullable Double d) { this.variation5 = d; return this; } @@ -581,7 +581,7 @@ public class Measure<G extends Serializable> implements Serializable { * * @since 2.5 */ - public Measure setVariation(int index, Double d) { + public Measure<G> setVariation(int index, Double d) { switch (index) { case 1: variation1 = d; @@ -617,7 +617,7 @@ public class Measure<G extends Serializable> implements Serializable { * @param url the url * @return the measure object instance */ - public Measure setUrl(String url) { + public Measure<G> setUrl(String url) { this.url = url; return this; } @@ -633,7 +633,7 @@ public class Measure<G extends Serializable> implements Serializable { /** * @since 4.1 */ - public final Measure setCharacteristic(@Nullable Characteristic characteristic) { + public final Measure<G> setCharacteristic(@Nullable Characteristic characteristic) { this.characteristic = characteristic; return this; } @@ -653,7 +653,7 @@ public class Measure<G extends Serializable> implements Serializable { * @deprecated since 4.3 */ @Deprecated - public final Measure setRequirement(@Nullable Requirement requirement) { + public final Measure<G> setRequirement(@Nullable Requirement requirement) { this.requirement = requirement; return this; } @@ -671,7 +671,7 @@ public class Measure<G extends Serializable> implements Serializable { * @since 2.14 */ @Beta - public Measure setPersonId(@Nullable Integer i) { + public Measure<G> setPersonId(@Nullable Integer i) { this.personId = i; return this; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java index b02bc030b8e..8eaef70b9f5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java @@ -289,7 +289,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a /** * For internal use only */ - public Metric setId(@Nullable Integer id) { + public Metric<G> setId(@Nullable Integer id) { this.id = id; return this; } @@ -307,7 +307,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a * @param formula the formula * @return this */ - public Metric setFormula(Formula formula) { + public Metric<G> setFormula(Formula formula) { this.formula = formula; return this; } @@ -325,7 +325,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a * @param qualitative whether the metric is qualitative * @return this */ - public Metric setQualitative(Boolean qualitative) { + public Metric<G> setQualitative(Boolean qualitative) { this.qualitative = qualitative; return this; } @@ -343,7 +343,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a * @param key the key * @return this */ - public Metric setKey(String key) { + public Metric<G> setKey(String key) { this.key = key; return this; } @@ -361,7 +361,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a * @param type the type * @return this */ - public Metric setType(ValueType type) { + public Metric<G> setType(ValueType type) { this.type = type; return this; } @@ -380,7 +380,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a * @param description the description * @return this */ - public Metric setDescription(@Nullable String description) { + public Metric<G> setDescription(@Nullable String description) { this.description = description; return this; } @@ -398,7 +398,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a * @param userManaged whether the metric is user managed * @return this */ - public Metric setUserManaged(Boolean userManaged) { + public Metric<G> setUserManaged(Boolean userManaged) { this.userManaged = userManaged; return this; } @@ -416,7 +416,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a * @param enabled whether the metric is enabled * @return this */ - public Metric setEnabled(Boolean enabled) { + public Metric<G> setEnabled(Boolean enabled) { this.enabled = enabled; return this; } @@ -433,7 +433,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a * * @param direction the direction */ - public Metric setDirection(Integer direction) { + public Metric<G> setDirection(Integer direction) { this.direction = direction; return this; } @@ -451,7 +451,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a * @param domain the domain * @return this */ - public Metric setDomain(String domain) { + public Metric<G> setDomain(String domain) { this.domain = domain; return this; } @@ -469,7 +469,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a * @param name the name * @return this */ - public Metric setName(String name) { + public Metric<G> setName(String name) { this.name = name; return this; } @@ -486,7 +486,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a /** * @return this */ - public Metric setWorstValue(@Nullable Double d) { + public Metric<G> setWorstValue(@Nullable Double d) { this.worstValue = d; return this; } @@ -495,7 +495,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a * @param bestValue the best value. It can be null. * @return this */ - public Metric setBestValue(@Nullable Double bestValue) { + public Metric<G> setBestValue(@Nullable Double bestValue) { this.bestValue = bestValue; return this; } @@ -527,7 +527,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a return ValueType.PERCENT.equals(type); } - public Metric setOptimizedBestValue(@Nullable Boolean b) { + public Metric<G> setOptimizedBestValue(@Nullable Boolean b) { this.optimizedBestValue = b; return this; } @@ -544,7 +544,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a return hidden; } - public Metric setHidden(Boolean hidden) { + public Metric<G> setHidden(Boolean hidden) { this.hidden = hidden; return this; } @@ -580,7 +580,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a * * @return this */ - public Metric merge(final Metric with) { + public Metric<G> merge(final Metric with) { this.description = with.description; this.domain = with.domain; this.enabled = with.enabled; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java index 418caff6e84..3f6654a6aaf 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java @@ -26,18 +26,22 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.collect.Sets; + import java.io.IOException; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; + import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; + import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; @@ -351,7 +355,7 @@ public interface WebService extends Definable<WebService.Context> { * Creates the parameter {@link org.sonar.api.server.ws.WebService.Param#FIELDS}, which is * used to restrict the number of fields returned in JSON response. */ - public NewAction addFieldsParam(Collection possibleValues) { + public NewAction addFieldsParam(Collection<?> possibleValues) { createParam(Param.FIELDS) .setDescription("Comma-separated list of the fields to be returned in response. All the fields are returned by default.") .setPossibleValues(possibleValues); @@ -565,7 +569,7 @@ public interface WebService extends Definable<WebService.Context> { * @since 4.4 */ public NewParam setPossibleValues(@Nullable Object... values) { - return setPossibleValues(values == null ? (Collection) null : Arrays.asList(values)); + return setPossibleValues(values == null ? Collections.emptyList() : Arrays.asList(values)); } /** @@ -581,7 +585,7 @@ public interface WebService extends Definable<WebService.Context> { * * @since 4.4 */ - public NewParam setPossibleValues(@Nullable Collection values) { + public NewParam setPossibleValues(@Nullable Collection<?> values) { if (values == null || values.isEmpty()) { this.possibleValues = null; } else { diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/WebServiceTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/WebServiceTest.java index 006aae7c064..6e1b4fc01a6 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/WebServiceTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/WebServiceTest.java @@ -328,10 +328,10 @@ public class WebServiceTest { NewAction create = newController.createAction("create").setHandler(mock(RequestHandler.class)); create.createParam("status") .setDefaultValue(null) - .setPossibleValues((Collection) null) + .setPossibleValues(Collections.emptyList()) .setExampleValue(null); create.createParam("max") - .setPossibleValues((String[]) null); + .setPossibleValues((Object[]) null); newController.done(); } }.define(context); |