Skip to content

Support using package-private classes as POJOs for InfluxDBResultMapper #457

Open
@leveluptor

Description

@leveluptor

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions