Skip to content

Commit

Permalink
drop support of Java 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
evernat committed Nov 22, 2020
1 parent c31cf8d commit e12d9c7
Show file tree
Hide file tree
Showing 141 changed files with 639 additions and 937 deletions.
11 changes: 9 additions & 2 deletions javamelody-core/.settings/org.eclipse.jdt.core.prefs
Expand Up @@ -10,13 +10,15 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.problem.APILeak=warning
org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
Expand All @@ -27,6 +29,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
Expand Down Expand Up @@ -85,12 +88,15 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warn
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
Expand All @@ -103,6 +109,7 @@ org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled
Expand All @@ -121,7 +128,7 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
Expand Down
4 changes: 2 additions & 2 deletions javamelody-core/pom.xml
Expand Up @@ -348,8 +348,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
<fork>true</fork>
<!-- pour éviter warning dans Maven sur sun.nio.ch.DirectBuffer dans
RrdNioBackend -->
Expand Down
Expand Up @@ -57,7 +57,7 @@ class CounterRequestAggregationData {
this.warningThreshold = aggregation.getWarningThreshold();
this.severeThreshold = aggregation.getSevereThreshold();

this.requests = new TreeMap<String, CounterRequestData>();
this.requests = new TreeMap<>();
final List<CounterRequest> requestList = aggregation.getRequests();
for (final CounterRequest request : requestList) {
requests.put(request.getName(), new CounterRequestData(request));
Expand Down
Expand Up @@ -62,7 +62,7 @@
* @author Emeric Vernat
*/
public class CustomResourceFilter implements Filter {
private final Map<String, String> customResources = new HashMap<String, String>();
private final Map<String, String> customResources = new HashMap<>();

/** {@inheritDoc} */
@Override
Expand Down
Expand Up @@ -65,7 +65,7 @@ class FilterContext {
private final Timer timer;
private final SamplingProfiler samplingProfiler;
private final TimerTask collectTimerTask;
private final Set<ObjectName> jmxNames = new HashSet<ObjectName>();
private final Set<ObjectName> jmxNames = new HashSet<>();

private static final class CollectTimerTask extends TimerTask {
private final Collector collector;
Expand Down Expand Up @@ -228,13 +228,9 @@ private static void setRequestTransformPatterns(List<Counter> counters) {

private static void setDisplayedCounters(List<Counter> counters, String displayedCounters) {
for (final Counter counter : counters) {
if (counter.isJobCounter()) {
// le compteur "job" a toujours displayed=true s'il est présent,
// même s'il n'est pas dans la liste des "displayedCounters"
counter.setDisplayed(true);
} else {
counter.setDisplayed(false);
}
// le compteur "job" a toujours displayed=true s'il est présent,
// même s'il n'est pas dans la liste des "displayedCounters"
counter.setDisplayed(counter.isJobCounter());
}
if (!displayedCounters.isEmpty()) {
for (final String displayedCounter : displayedCounters.split(",")) {
Expand Down
Expand Up @@ -66,7 +66,7 @@ public final class JdbcWrapper {
static final AtomicInteger RUNNING_BUILD_COUNT = new AtomicInteger();
static final AtomicInteger BUILD_QUEUE_LENGTH = new AtomicInteger();
static final AtomicLong BUILD_QUEUE_WAITING_DURATIONS_SUM = new AtomicLong();
static final Map<Integer, ConnectionInformations> USED_CONNECTION_INFORMATIONS = new ConcurrentHashMap<Integer, ConnectionInformations>();
static final Map<Integer, ConnectionInformations> USED_CONNECTION_INFORMATIONS = new ConcurrentHashMap<>();

private static final int MAX_USED_CONNECTION_INFORMATIONS = 500;

Expand Down Expand Up @@ -359,7 +359,7 @@ public static long getBuildQueueWaitingDurationsSum() {
}

public static List<ConnectionInformations> getConnectionInformationsList() {
final List<ConnectionInformations> result = new ArrayList<ConnectionInformations>(
final List<ConnectionInformations> result = new ArrayList<>(
USED_CONNECTION_INFORMATIONS.values());
Collections.sort(result, new ConnectionInformationsComparator());
return Collections.unmodifiableList(result);
Expand Down
Expand Up @@ -49,9 +49,9 @@
*/
final class JdbcWrapperHelper {
private static final String MAX_ACTIVE_PROPERTY_NAME = "maxActive";
private static final Map<String, DataSource> SPRING_DATASOURCES = new LinkedHashMap<String, DataSource>();
private static final Map<String, DataSource> JNDI_DATASOURCES_BACKUP = new LinkedHashMap<String, DataSource>();
private static final Map<String, DataSource> REWRAPPED_DATASOURCES_BACKUP = new LinkedHashMap<String, DataSource>();
private static final Map<String, DataSource> SPRING_DATASOURCES = new LinkedHashMap<>();
private static final Map<String, DataSource> JNDI_DATASOURCES_BACKUP = new LinkedHashMap<>();
private static final Map<String, DataSource> REWRAPPED_DATASOURCES_BACKUP = new LinkedHashMap<>();
private static final BasicDataSourcesProperties TOMCAT_BASIC_DATASOURCES_PROPERTIES = new BasicDataSourcesProperties();
private static final BasicDataSourcesProperties DBCP_BASIC_DATASOURCES_PROPERTIES = new BasicDataSourcesProperties();
private static final BasicDataSourcesProperties TOMCAT_JDBC_DATASOURCES_PROPERTIES = new BasicDataSourcesProperties();
Expand All @@ -64,7 +64,7 @@ final class JdbcWrapperHelper {
* @author Emeric Vernat
*/
private static class BasicDataSourcesProperties {
private final Map<String, Map<String, Object>> properties = new LinkedHashMap<String, Map<String, Object>>();
private final Map<String, Map<String, Object>> properties = new LinkedHashMap<>();

BasicDataSourcesProperties() {
super();
Expand All @@ -88,7 +88,7 @@ int getMaxActive() {
}

Map<String, Map<String, Object>> getDataSourcesProperties() {
final Map<String, Map<String, Object>> result = new LinkedHashMap<String, Map<String, Object>>();
final Map<String, Map<String, Object>> result = new LinkedHashMap<>();
for (final Map.Entry<String, Map<String, Object>> entry : properties.entrySet()) {
result.put(entry.getKey(), Collections.unmodifiableMap(entry.getValue()));
}
Expand All @@ -98,7 +98,7 @@ Map<String, Map<String, Object>> getDataSourcesProperties() {
void put(String dataSourceName, String key, Object value) {
Map<String, Object> dataSourceProperties = properties.get(dataSourceName);
if (dataSourceProperties == null) {
dataSourceProperties = new LinkedHashMap<String, Object>();
dataSourceProperties = new LinkedHashMap<>();
properties.put(dataSourceName, dataSourceProperties);
}
dataSourceProperties.put(key, value);
Expand Down Expand Up @@ -150,16 +150,16 @@ static void rebindInitialDataSources(ServletContext servletContext) throws Throw
static Map<String, DataSource> getJndiAndSpringDataSources() throws NamingException {
Map<String, DataSource> dataSources;
try {
dataSources = new LinkedHashMap<String, DataSource>(getJndiDataSources());
dataSources = new LinkedHashMap<>(getJndiDataSources());
} catch (final NoInitialContextException e) {
dataSources = new LinkedHashMap<String, DataSource>();
dataSources = new LinkedHashMap<>();
}
dataSources.putAll(SPRING_DATASOURCES);
return dataSources;
}

static Map<String, DataSource> getJndiDataSources() throws NamingException {
final Map<String, DataSource> dataSources = new LinkedHashMap<String, DataSource>(2);
final Map<String, DataSource> dataSources = new LinkedHashMap<>(2);
final String datasourcesParameter = Parameter.DATASOURCES.getValue();
if (datasourcesParameter == null) {
dataSources.putAll(getJndiDataSourcesAt("java:comp/env/jdbc"));
Expand Down Expand Up @@ -187,7 +187,7 @@ static Map<String, DataSource> getJndiDataSources() throws NamingException {
private static Map<String, DataSource> getJndiDataSourcesAt(String jndiPrefix)
throws NamingException {
final InitialContext initialContext = new InitialContext();
final Map<String, DataSource> dataSources = new LinkedHashMap<String, DataSource>(2);
final Map<String, DataSource> dataSources = new LinkedHashMap<>(2);
try {
for (final NameClassPair nameClassPair : Collections
.list(initialContext.list(jndiPrefix))) {
Expand Down Expand Up @@ -557,7 +557,7 @@ static void clearProxyCache() {
@SuppressWarnings("unchecked")
static <T> T createProxy(T object, InvocationHandler invocationHandler,
List<Class<?>> interfaces) {
final Class<? extends Object> objectClass = object.getClass();
final Class<?> objectClass = object.getClass();
// ce handler désencapsule les InvocationTargetException des 3 proxy
// avant : return (T) Proxy.newProxyInstance(objectClass.getClassLoader(), getObjectInterfaces(objectClass, interfaces), ih);
// maintenant (optimisé) :
Expand All @@ -578,7 +578,7 @@ static <T> T createProxy(T object, InvocationHandler invocationHandler,
}
}

private static Constructor<?> getProxyConstructor(Class<? extends Object> objectClass,
private static Constructor<?> getProxyConstructor(Class<?> objectClass,
Class<?>[] interfacesArray) {
final ClassLoader classLoader = objectClass.getClassLoader();
try {
Expand All @@ -600,7 +600,7 @@ private static Class<?>[] getObjectInterfaces(Class<?> objectClass, List<Class<?
// et connection.getClass().getInterfaces() est vide dans ce cas
final List<Class<?>> myInterfaces;
if (interfaces == null) {
myInterfaces = new ArrayList<Class<?>>(Arrays.asList(objectClass.getInterfaces()));
myInterfaces = new ArrayList<>(Arrays.asList(objectClass.getInterfaces()));
Class<?> classe = objectClass.getSuperclass();
while (classe != null) {
final Class<?>[] classInterfaces = classe.getInterfaces();
Expand Down
Expand Up @@ -71,7 +71,7 @@ enum JpaMethod {
}

static JpaMethod forCall(Method method, Object[] args) {
for (final JpaMethod type : JpaMethod.values()) {
for (final JpaMethod type : values()) {
if (type.matcher.matches(type, method, args)) {
return type;
}
Expand Down
Expand Up @@ -75,7 +75,7 @@ public URL getResource(final String name) {
public Enumeration<URL> getResources(final String name) throws IOException {
final Enumeration<URL> urls = super.getResources(name);
if (PERSISTENCE_XML.equals(name)) {
final Collection<URL> overrided = new LinkedList<URL>();
final Collection<URL> overrided = new LinkedList<>();
while (urls.hasMoreElements()) {
final URL url = urls.nextElement();
overrided.add(newUrl(url, slurp(url)));
Expand All @@ -101,11 +101,8 @@ private URL newUrl(final URL url, final String slurp) {

private static String slurp(final URL url) {
try {
final InputStream is = url.openStream();
try {
try (InputStream is = url.openStream()) {
return InputOutput.pumpToString(is, Charset.defaultCharset());
} finally {
is.close();
}
} catch (final IOException e) {
throw new IllegalStateException(e);
Expand Down
Expand Up @@ -102,7 +102,7 @@ public List<PersistenceProvider> getPersistenceProviders() {
// on met notre JpaPersistence en premier pour qu'il soit toujours choisi
// et qu'il délègue au persistence provider final
final List<PersistenceProvider> providers = delegate.getPersistenceProviders();
final List<PersistenceProvider> result = new ArrayList<PersistenceProvider>();
final List<PersistenceProvider> result = new ArrayList<>();
for (final PersistenceProvider provider : providers) {
if (provider instanceof JpaPersistence) {
result.add(0, provider);
Expand Down
Expand Up @@ -61,7 +61,7 @@ public class MonitoringFilter implements Filter {

private static boolean instanceCreated;

private static final List<String> CONTEXT_PATHS = new ArrayList<String>();
private static final List<String> CONTEXT_PATHS = new ArrayList<>();

private static URL unregisterApplicationNodeInCollectServerUrl;

Expand Down
Expand Up @@ -63,11 +63,7 @@ public Context getInitialContext(Hashtable<?, ?> environment) throws NamingExcep
final Context context = icf.getInitialContext(environment);
final JdbcWrapper jdbcWrapper = JdbcWrapper.SINGLETON;
return jdbcWrapper.createContextProxy(context);
} catch (final ClassNotFoundException e) {
throw createNamingException(e);
} catch (final InstantiationException e) {
throw createNamingException(e);
} catch (final IllegalAccessException e) {
} catch (final ClassNotFoundException | IllegalAccessException | InstantiationException e) {
throw createNamingException(e);
}
}
Expand Down
Expand Up @@ -70,7 +70,7 @@ public class SessionListener implements HttpSessionListener, HttpSessionActivati
@SuppressWarnings("all")
private static final ConcurrentMap<String, HttpSession> SESSION_MAP_BY_ID = new ConcurrentHashMap<String, HttpSession>();

private static final ThreadLocal<HttpSession> SESSION_CONTEXT = new ThreadLocal<HttpSession>();
private static final ThreadLocal<HttpSession> SESSION_CONTEXT = new ThreadLocal<>();

private static boolean instanceCreated;

Expand Down Expand Up @@ -226,8 +226,8 @@ private static void removeSession(final HttpSession session) {

public static List<SessionInformations> getAllSessionsInformations() {
final Collection<HttpSession> sessions = SESSION_MAP_BY_ID.values();
final List<SessionInformations> sessionsInformations = new ArrayList<SessionInformations>(
sessions.size());
final List<SessionInformations> sessionsInformations = new ArrayList<>(
sessions.size());
for (final HttpSession session : sessions) {
try {
sessionsInformations.add(new SessionInformations(session, false));
Expand Down
Expand Up @@ -64,8 +64,8 @@ public Object postProcessAfterInitialization(Object bean, String beanName) {
// RestTemplate et getInterceptors() existent depuis spring-web 3.1.0.RELEASE
if (REST_TEMPLATE_INTERCEPTOR_AVAILABLE && bean instanceof RestTemplate) {
final RestTemplate restTemplate = (RestTemplate) bean;
final List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>(
restTemplate.getInterceptors());
final List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>(
restTemplate.getInterceptors());
for (final ClientHttpRequestInterceptor interceptor : interceptors) {
if (interceptor instanceof SpringRestTemplateInterceptor) {
return bean;
Expand All @@ -84,11 +84,7 @@ private static boolean isRestTemplateInterceptorAvailable() {
final Class<?> clazz = Class.forName("org.springframework.web.client.RestTemplate");
clazz.getMethod("getInterceptors");
return true;
} catch (final ClassNotFoundException e) {
return false;
} catch (final NoSuchMethodException e) {
return false;
} catch (final SecurityException e) {
} catch (final ClassNotFoundException | SecurityException | NoSuchMethodException e) {
return false;
}
}
Expand Down
Expand Up @@ -52,13 +52,10 @@ public ClientHttpResponse intercept(HttpRequest httpRequest, byte[] body,
// we could add in httpRequest.getHeaders() a javamelody id
// to link, in the collector server, the callers in this jvm to the callees in the jvm called
return execution.execute(httpRequest, body);
} catch (final IOException e) {
} catch (final IOException | Error e) {
// IOException - in case of I/O errors
systemError = true;
throw e;
} catch (final Error e) {
systemError = true;
throw e;
} finally {
// on enregistre la requête dans les statistiques
SPRING_COUNTER.addRequestForCurrentContext(systemError);
Expand Down
Expand Up @@ -42,7 +42,7 @@ public final class I18N {
// (Parameters.getResourcePath("translations") seul ne fonctionne pas si on est dans un jar/war)
private static final String RESOURCE_BUNDLE_BASE_NAME = Parameters
.getResourcePath("translations").replace('/', '.').substring(1);
private static final ThreadLocal<Locale> LOCALE_CONTEXT = new ThreadLocal<Locale>();
private static final ThreadLocal<Locale> LOCALE_CONTEXT = new ThreadLocal<>();
// Locale.ROOT needs 1.6
private static final Locale ROOT_LOCALE = Locale.ROOT;

Expand Down

0 comments on commit e12d9c7

Please sign in to comment.