Skip to content
This repository was archived by the owner on Dec 23, 2023. It is now read-only.

Commit 0d93f65

Browse files
committed
Instantiates CensusContextFactoryImpl with Class.getConstructor().newInstance().
1 parent 5bf6916 commit 0d93f65

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

core/java/com/google/census/Provider.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
package com.google.census;
1515

16+
import java.lang.reflect.InvocationTargetException;
17+
1618
/**
1719
* Census-specific service provider mechanism.
1820
*
@@ -40,14 +42,20 @@ class Provider<T> {
4042
T newInstance() {
4143
try {
4244
if (provider != null) {
43-
return (T) provider.newInstance();
45+
return (T) provider.getConstructor().newInstance();
4446
}
4547
} catch (InstantiationException e) {
4648
// TODO(dpo): decide what to do here - log, crash, or both.
4749
System.err.println(e);
4850
} catch (IllegalAccessException e) {
4951
// TODO(dpo): decide what to do here - log, crash, or both.
5052
System.err.println(e);
53+
} catch (NoSuchMethodException e) {
54+
// TODO(dpo): decide what to do here - log, crash, or both.
55+
System.err.println(e);
56+
} catch (InvocationTargetException e) {
57+
// TODO(dpo): decide what to do here - log, crash, or both.
58+
System.err.println(e);
5159
}
5260
return null;
5361
}

core_native/java/com/google/census/CensusContextFactoryImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
final class CensusContextFactoryImpl extends CensusContextFactory {
2222
static final CensusContextImpl DEFAULT = new CensusContextImpl(new HashMap<String, String>(0));
2323

24+
public CensusContextFactoryImpl() {}
25+
2426
/**
2527
* Deserializes a {@link CensusContextImpl} from a serialized {@code CensusContextProto}.
2628
*

0 commit comments

Comments
 (0)