beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Wegner (JIRA)" <>
Subject [jira] [Created] (BEAM-308) PipelineOptions throws when using package-private PipelineOptions interfaces from multiple packages
Date Wed, 25 May 2016 18:08:14 GMT
Scott Wegner created BEAM-308:

             Summary: PipelineOptions throws when using package-private PipelineOptions interfaces
from multiple packages
                 Key: BEAM-308
             Project: Beam
          Issue Type: Bug
          Components: sdk-java-core
            Reporter: Scott Wegner
            Assignee: Scott Wegner
            Priority: Minor

If a PipelineOptions instance is used as multiple PipelineOptions package-private interfaces
from different packages, {{}} will throw an exception:

java.lang.IllegalArgumentException: non-public interfaces from different packages

	at java.lang.reflect.Proxy$ProxyClassFactory.apply(
	at java.lang.reflect.Proxy$ProxyClassFactory.apply(
	at java.lang.reflect.WeakCache$Factory.get(
	at java.lang.reflect.WeakCache.get(
	at java.lang.reflect.Proxy.getProxyClass0(
	at java.lang.reflect.Proxy.getProxyClass(
	at org.apache.beam.sdk.options.PipelineOptionsFactory.validateWellFormed(
	at org.apache.beam.sdk.options.ProxyInvocationHandler.invoke(
	at com.sun.proxy.$ Source)

This fails because ProxyInvocationHandler attempts to create a Java Proxy object implementing
the full set of interfaces, which has the [restriction|,%20java.lang.Class...)]:

bq. All non-public interfaces must be in the same package; otherwise, it would not be possible
for the proxy class to implement all of the interfaces, regardless of what package it is defined

This can be triggered in a couple edge-case scenarios:

# {{}} is called on the same PipelineOptions instance with multiple package-private
# {{PipelineOptionsFactory.register}} is called with a package-private interface, and then
{{}} is called with a different package-private instance.

We hit the second scenario in [DataflowSDK unit tests|].
It's hard to trigger, but possible.


I propose we make the behavior for package-private options explicit:

# Give a better exception message if we hit this issue in {{}} listing the
non-public interfaces and what packages they're in.
# Explicitly reject non-public interfaces from {{PipelineOptionsFactory.register}}, since
this state is global and is easier to cause issues.

This message was sent by Atlassian JIRA

View raw message