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 85DBC200D4A for ; Tue, 28 Nov 2017 18:38:06 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 8471D160BE7; Tue, 28 Nov 2017 17:38:06 +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 A622E160C07 for ; Tue, 28 Nov 2017 18:38:05 +0100 (CET) Received: (qmail 89332 invoked by uid 500); 28 Nov 2017 17:38:04 -0000 Mailing-List: contact commits-help@beam.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@beam.apache.org Delivered-To: mailing list commits@beam.apache.org Received: (qmail 89323 invoked by uid 99); 28 Nov 2017 17:38:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Nov 2017 17:38:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 09F1D18078B for ; Tue, 28 Nov 2017 17:38:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id nFYi8MLhODT5 for ; Tue, 28 Nov 2017 17:38:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id CA6C45F568 for ; Tue, 28 Nov 2017 17:38:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 13F4BE0E80 for ; Tue, 28 Nov 2017 17:38:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 7D06C241C7 for ; Tue, 28 Nov 2017 17:38:00 +0000 (UTC) Date: Tue, 28 Nov 2017 17:38:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: commits@beam.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (BEAM-3243) multiple anonymous DoFn lead to conflicting names MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 28 Nov 2017 17:38:06 -0000 [ https://issues.apache.org/jira/browse/BEAM-3243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16269113#comment-16269113 ] ASF GitHub Bot commented on BEAM-3243: -------------------------------------- rmannibucau closed pull request #4172: [BEAM-3243] support multiple anonymous classes from the same enclosing class in a pipeline URL: https://github.com/apache/beam/pull/4172 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/util/NameUtils.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/util/NameUtils.java index 3f3054ae733..d42e41c059e 100644 --- a/sdks/java/core/src/main/java/org/apache/beam/sdk/util/NameUtils.java +++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/util/NameUtils.java @@ -52,8 +52,6 @@ private static final String ANONYMOUS_CLASS_REGEX = "\\$[0-9]+\\$"; private static String approximateSimpleName(Class clazz, boolean dropOuterClassNames) { - checkArgument(!clazz.isAnonymousClass(), - "Attempted to get simple name of anonymous class"); return approximateSimpleName(clazz.getName(), dropOuterClassNames); } @@ -92,14 +90,6 @@ private static String simplifyNameComponent(String name) { return name; } - /** - * As {@link #approximateSimpleName(Object, String)} but returning {@code "Anonymous"} when - * {@code object} is an instance of anonymous class. - */ - public static String approximateSimpleName(Object object) { - return approximateSimpleName(object, "Anonymous"); - } - /** * Returns a simple name describing a class that is being used as a function (eg., a {@link DoFn} * or {@link CombineFn}, etc.). @@ -123,7 +113,7 @@ public static String approximateSimpleName(Object object) { *
  • {@code another.package.PairingFn} becomes "Pairing" * */ - public static String approximateSimpleName(Object object, String anonymousValue) { + public static String approximateSimpleName(Object object) { if (object instanceof NameOverride) { return ((NameOverride) object).getNameOverride(); } @@ -134,9 +124,11 @@ public static String approximateSimpleName(Object object, String anonymousValue) } else { clazz = object.getClass(); } + /* if anonymous ensure the name is unique to support multiple anonymous DoFn per class if (clazz.isAnonymousClass()) { return anonymousValue; } + */ return approximateSimpleName(clazz, /* dropOuterClassNames */ true); } diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/util/NameUtilsTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/util/NameUtilsTest.java index 411f91317e0..fb17e149d95 100644 --- a/sdks/java/core/src/test/java/org/apache/beam/sdk/util/NameUtilsTest.java +++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/util/NameUtilsTest.java @@ -77,6 +77,9 @@ public void testDropsOuterClassNamesFalse() { * Inner class for simple name test. */ private class EmbeddedDoFn { + private Object anonymous() { // ensure we have a single one for the test + return new DeeperEmbeddedDoFn() {}; + } private class DeeperEmbeddedDoFn extends EmbeddedDoFn {} @@ -114,7 +117,7 @@ public void testSimpleName() { @Test public void testAnonSimpleName() throws Exception { - assertEquals("Anonymous", NameUtils.approximateSimpleName(new EmbeddedDoFn() {})); + assertEquals("Embedded$1", NameUtils.approximateSimpleName(new EmbeddedDoFn().anonymous())); } @Test @@ -180,10 +183,4 @@ public String getNameOverride() { }; assertEquals("CUSTOM_NAME", NameUtils.approximateSimpleName(overriddenName)); } - - @Test - public void testApproximateSimpleNameCustomAnonymous() { - Object overriddenName = new Object() {}; - assertEquals("CUSTOM_NAME", NameUtils.approximateSimpleName(overriddenName, "CUSTOM_NAME")); - } } ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org > multiple anonymous DoFn lead to conflicting names > ------------------------------------------------- > > Key: BEAM-3243 > URL: https://issues.apache.org/jira/browse/BEAM-3243 > Project: Beam > Issue Type: Task > Components: sdk-java-core > Reporter: Romain Manni-Bucau > Assignee: Romain Manni-Bucau > Fix For: 2.3.0 > > -- This message was sent by Atlassian JIRA (v6.4.14#64029)