Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EB4FA200A5B for ; Wed, 25 May 2016 23:12:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EA10A160A0F; Wed, 25 May 2016 21:12:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3C1BA160A29 for ; Wed, 25 May 2016 23:12:07 +0200 (CEST) Received: (qmail 76002 invoked by uid 500); 25 May 2016 20:40:53 -0000 Mailing-List: contact commits-help@beam.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@beam.incubator.apache.org Delivered-To: mailing list commits@beam.incubator.apache.org Received: (qmail 75993 invoked by uid 99); 25 May 2016 20:40:53 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 May 2016 20:40:53 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 09DA8CD3C8 for ; Wed, 25 May 2016 20:40:53 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id GR5atCVvxJnc for ; Wed, 25 May 2016 20:40:50 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id E34E55FB9E for ; Wed, 25 May 2016 20:40:49 +0000 (UTC) Received: (qmail 96707 invoked by uid 99); 25 May 2016 20:19:13 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 May 2016 20:19:13 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 708022C1F85 for ; Wed, 25 May 2016 20:19:13 +0000 (UTC) Date: Wed, 25 May 2016 20:19:13 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: commits@beam.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (BEAM-308) PipelineOptions throws when using package-private PipelineOptions interfaces from multiple packages MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 25 May 2016 21:12:08 -0000 [ https://issues.apache.org/jira/browse/BEAM-308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15300778#comment-15300778 ] ASF GitHub Bot commented on BEAM-308: ------------------------------------- Github user asfgit closed the pull request at: https://github.com/apache/incubator-beam/pull/390 > PipelineOptions throws when using package-private PipelineOptions interfaces from multiple packages > --------------------------------------------------------------------------------------------------- > > Key: BEAM-308 > URL: https://issues.apache.org/jira/browse/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, {{PipelineOptions.as}} will throw an exception: > {quote} > java.lang.IllegalArgumentException: non-public interfaces from different packages > at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:652) > at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:592) > at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:244) > at java.lang.reflect.WeakCache.get(WeakCache.java:141) > at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:455) > at java.lang.reflect.Proxy.getProxyClass(Proxy.java:405) > at org.apache.beam.sdk.options.PipelineOptionsFactory.validateWellFormed(PipelineOptionsFactory.java:620) > at org.apache.beam.sdk.options.ProxyInvocationHandler.as(ProxyInvocationHandler.java:209) > at org.apache.beam.sdk.options.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:135) > at com.sun.proxy.$Proxy6.as(Unknown Source) > {quote} > This fails because ProxyInvocationHandler attempts to create a Java Proxy object implementing the full set of interfaces, which has the [restriction|https://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Proxy.html#getProxyClass(java.lang.ClassLoader,%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 in. > This can be triggered in a couple edge-case scenarios: > # {{PipelineOptions.as}} is called on the same PipelineOptions instance with multiple package-private interfaces. > # {{PipelineOptionsFactory.register}} is called with a package-private interface, and then {{PipelineOptions.as}} is called with a different package-private instance. > We hit the second scenario in [DataflowSDK unit tests|https://github.com/GoogleCloudPlatform/DataflowJavaSDK/pull/286#issuecomment-221438063]. 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 {{PipelineOptions.as}} 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 (v6.3.4#6332)