Skip to content

Commit 1d12baf

Browse files
committed
Remove deprecated usage of newInstance and some other methods.
1 parent 9826219 commit 1d12baf

21 files changed

+152
-33
lines changed

.classpath

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
13+
<attribute name="test" value="true"/>
14+
</attributes>
15+
</classpathentry>
16+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
17+
<attributes>
18+
<attribute name="maven.pomderived" value="true"/>
19+
<attribute name="test" value="true"/>
20+
</attributes>
21+
</classpathentry>
22+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
23+
<attributes>
24+
<attribute name="maven.pomderived" value="true"/>
25+
</attributes>
26+
</classpathentry>
27+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
28+
<attributes>
29+
<attribute name="maven.pomderived" value="true"/>
30+
</attributes>
31+
</classpathentry>
32+
<classpathentry kind="src" path="target/generated-sources/annotations">
33+
<attributes>
34+
<attribute name="optional" value="true"/>
35+
<attribute name="maven.pomderived" value="true"/>
36+
<attribute name="ignore_optional_problems" value="true"/>
37+
<attribute name="m2e-apt" value="true"/>
38+
</attributes>
39+
</classpathentry>
40+
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
41+
<attributes>
42+
<attribute name="optional" value="true"/>
43+
<attribute name="maven.pomderived" value="true"/>
44+
<attribute name="ignore_optional_problems" value="true"/>
45+
<attribute name="m2e-apt" value="true"/>
46+
<attribute name="test" value="true"/>
47+
</attributes>
48+
</classpathentry>
49+
<classpathentry kind="output" path="target/classes"/>
50+
</classpath>

.project

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>zalando-sprocwrapper</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
<filteredResources>
24+
<filter>
25+
<id>1616103069919</id>
26+
<name></name>
27+
<type>30</type>
28+
<matcher>
29+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
30+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31+
</matcher>
32+
</filter>
33+
</filteredResources>
34+
</projectDescription>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
eclipse.preferences.version=1
2+
encoding//src/main/java=UTF-8
3+
encoding//src/test/java=UTF-8
4+
encoding//src/test/resources=UTF-8
5+
encoding/<project>=UTF-8
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.apt.aptEnabled=false

.settings/org.eclipse.jdt.core.prefs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.compliance=1.8
5+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
6+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
7+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
8+
org.eclipse.jdt.core.compiler.processAnnotations=disabled
9+
org.eclipse.jdt.core.compiler.release=disabled
10+
org.eclipse.jdt.core.compiler.source=1.8

.settings/org.eclipse.m2e.core.prefs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1

src/main/java/org/zalando/sprocwrapper/dsprovider/BitmapShardDataSourceProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public BitmapShardDataSourceProvider(final Map<String, DataSource> connectionDat
7575

7676
public BitmapShardDataSourceProvider(final Class<? extends DataSource> dataSourceClass,
7777
final Map<String, String> commonDataSourceProperties, final Map<String, String> connectionUrls)
78-
throws InstantiationException, IllegalAccessException, InvocationTargetException {
78+
throws InstantiationException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException {
7979

8080
int maskLength = 0;
8181
for (final Entry<String, String> entry : connectionUrls.entrySet()) {
@@ -88,7 +88,7 @@ public BitmapShardDataSourceProvider(final Class<? extends DataSource> dataSourc
8888
dataSources = new DataSource[1 << maskLength];
8989

9090
for (final Entry<String, String> entry : connectionUrls.entrySet()) {
91-
final DataSource ds = dataSourceClass.newInstance();
91+
final DataSource ds = dataSourceClass.getDeclaredConstructor().newInstance();
9292
for (final Entry<String, String> prop : commonDataSourceProperties.entrySet()) {
9393
BeanUtils.setProperty(ds, prop.getKey(), prop.getValue());
9494
}

src/main/java/org/zalando/sprocwrapper/globalobjecttransformer/GlobalObjectTransformerLoader.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.reflections.util.ClasspathHelper;
1212
import org.reflections.util.ConfigurationBuilder;
1313
import org.reflections.util.FilterBuilder;
14+
import java.lang.reflect.InvocationTargetException;
1415
import org.slf4j.Logger;
1516
import org.slf4j.LoggerFactory;
1617

@@ -33,7 +34,7 @@ public class GlobalObjectTransformerLoader {
3334
private static volatile ImmutableMap<Class<?>, ObjectMapper<?>> register;
3435

3536
public static <T> ObjectMapper<T> getObjectMapperForClass(final Class<T> genericType) throws InstantiationException,
36-
IllegalAccessException {
37+
IllegalAccessException, InvocationTargetException, SecurityException, IllegalArgumentException, NoSuchMethodException, InvocationTargetException {
3738
Preconditions.checkNotNull(genericType, "genericType");
3839

3940
// performance improvement. Volatile field is read only once in the commons scenario.
@@ -55,15 +56,15 @@ public static <T> ObjectMapper<T> getObjectMapperForClass(final Class<T> generic
5556
}
5657

5758
private static ImmutableMap<Class<?>, ObjectMapper<?>> buildMappers() throws InstantiationException,
58-
IllegalAccessException {
59+
IllegalAccessException, InvocationTargetException, SecurityException, IllegalArgumentException, NoSuchMethodException, InvocationTargetException {
5960

6061
final Map<Class<?>, ObjectMapper<?>> mappers = new HashMap<>();
6162

6263
for (final Class<?> foundGlobalObjectTransformer : findObjectMappers()) {
6364

6465
if (ObjectMapper.class.isAssignableFrom(foundGlobalObjectTransformer)) {
6566

66-
final ObjectMapper<?> mapper = (ObjectMapper<?>) foundGlobalObjectTransformer.newInstance();
67+
final ObjectMapper<?> mapper = (ObjectMapper<?>) foundGlobalObjectTransformer.getDeclaredConstructor().newInstance();
6768
final Class<?> valueTransformerReturnType = mapper.getType();
6869

6970
final ObjectMapper<?> previousMapper = mappers.put(valueTransformerReturnType, mapper);

src/main/java/org/zalando/sprocwrapper/globalvaluetransformer/GlobalValueTransformerLoader.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.zalando.sprocwrapper.globalvaluetransformer;
22

3+
import java.lang.reflect.InvocationTargetException;
34
import java.util.Set;
45

56
import org.reflections.Reflections;
@@ -33,7 +34,7 @@ public class GlobalValueTransformerLoader {
3334
private static boolean scannedClasspath = false;
3435

3536
public static synchronized ValueTransformer<?, ?> getValueTransformerForClass(final Class<?> genericType)
36-
throws InstantiationException, IllegalAccessException {
37+
throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, InvocationTargetException {
3738

3839
// did we already scanned the classpath for global value transformers?
3940
if (scannedClasspath == false) {
@@ -71,7 +72,7 @@ public boolean apply(final String input) {
7172
valueTransformerReturnType = ValueTransformerUtils.getUnmarshalFromDbClass(
7273
foundGlobalValueTransformer);
7374
GlobalValueTransformerRegistry.register(valueTransformerReturnType,
74-
(ValueTransformer<?, ?>) foundGlobalValueTransformer.newInstance());
75+
(ValueTransformer<?, ?>) foundGlobalValueTransformer.getDeclaredConstructor().newInstance());
7576
} catch (final RuntimeException e) {
7677
LOG.error("Failed to add global transformer [{}] to global registry.",
7778
foundGlobalValueTransformer, e);

src/main/java/org/zalando/sprocwrapper/proxy/GlobalValueTransformedParameter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.zalando.sprocwrapper.proxy;
22

3+
import java.lang.reflect.InvocationTargetException;
34
import java.lang.reflect.Method;
45

56
import java.sql.Connection;
@@ -25,7 +26,7 @@ public class GlobalValueTransformedParameter extends StoredProcedureParameter {
2526

2627
public GlobalValueTransformedParameter(final ValueTransformer<?, ?> valueTransformerForClass, final Class<?> clazz,
2728
final Method m, final String typeName, final int javaPosition, final boolean sensitive,
28-
final ObjectMapper<?> globalObjectMapper) throws InstantiationException, IllegalAccessException {
29+
final ObjectMapper<?> globalObjectMapper) throws InstantiationException, IllegalAccessException, InvocationTargetException, SecurityException, IllegalArgumentException, NoSuchMethodException {
2930
super(getValueTransformedClazz(clazz, valueTransformerForClass), m, typeName, getValueTransformedTypeId(clazz),
3031
javaPosition, sensitive);
3132

0 commit comments

Comments
 (0)