influxdata / influxdata/influxdb-java
Support using package-private classes as POJOs for InfluxDBResultMapper
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 469
- PR merge metrics
- No merged PRs in 30d
Description
I'm using org.influxdb:influxdb-java:2.10.
I'd like to limit my @Measurement classes visibility to package-private, but currently it doesn't work because of the following exception:
org.influxdb.InfluxDBMapperException: java.lang.IllegalAccessException: Class org.influxdb.impl.InfluxDBResultMapper can not access a member of class com.example.MyMeasurement with modifiers "public"
The line which causes this is https://github.com/influxdata/influxdb-java/blob/influxdb-java-2.10/src/main/java/org/influxdb/impl/InfluxDBResultMapper.java#L160.
Looks like it will be enough to replace
object = clazz.newInstance();
with
Constructor<T> defaultConstructor = clazz.getDeclaredConstructor();
defaultConstructor.setAccessible(true);
object = declaredConstructor.newInstance();
If there are no objections, I'll provide a PR.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/main/java/org/influxdb/impl/InfluxDBResultMapper.java at line 160 and trace how measurement objects are instantiated. Verify the behavior with a package-private @Measurement class, and consider a regression test showing that mapping succeeds for this visibility level.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100