[ 
https://issues.apache.org/jira/browse/BEAM-5928?focusedWorklogId=162752&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-162752
 ]

ASF GitHub Bot logged work on BEAM-5928:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Nov/18 21:10
            Start Date: 05/Nov/18 21:10
    Worklog Time Spent: 10m 
      Work Description: reuvenlax closed pull request #6927: [BEAM-5928] Change 
hash map to concurrent map.
URL: https://github.com/apache/beam/pull/6927
 
 
   

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/coders/RowCoderGenerator.java
 
b/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/RowCoderGenerator.java
index 50be370adb0..b7485821911 100644
--- 
a/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/RowCoderGenerator.java
+++ 
b/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/RowCoderGenerator.java
@@ -101,12 +101,12 @@
   private static final Map<TypeName, StackManipulation> CODER_MAP;
 
   // Cache for Coder class that are already generated.
-  private static Map<UUID, Coder<Row>> generatedCoders = Maps.newHashMap();
+  private static Map<UUID, Coder<Row>> generatedCoders = 
Maps.newConcurrentMap();
 
   static {
     // Initialize the CODER_MAP with the StackManipulations to create the 
primitive coders.
     // Assumes that each class contains a static of() constructor method.
-    CODER_MAP = Maps.newHashMap();
+    CODER_MAP = Maps.newConcurrentMap();
     for (Map.Entry<TypeName, Coder> entry : RowCoder.CODER_MAP.entrySet()) {
       StackManipulation stackManipulation =
           MethodInvocation.invoke(


 

----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 162752)
    Time Spent: 50m  (was: 40m)

> ConcurrentModificationException from RowCoderGenerator lazy caching
> -------------------------------------------------------------------
>
>                 Key: BEAM-5928
>                 URL: https://issues.apache.org/jira/browse/BEAM-5928
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-core
>            Reporter: Benson Tucker
>            Assignee: Reuven Lax
>            Priority: Major
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> h3. Summary:
> RowCoderGenerator caches a delegate Coder<Row> once encode or decode is 
> exercised, but there's not an API for caching this delegate eagerly.
> h3. Use Case:
> When creating several PCollections to perform distinct reads with the same 
> schema, you might create one RowCoder.of(schema) before creating the list of 
> PCollections / PCollectionsList. However, once the pipeline begins and rows 
> arrive for encoding, these pipelines will simultaneously try to cache a 
> delegate coder for the row's schema. 
> h3. Workaround:
> You can force the eager caching of the code by exercising encode in the main 
> application before creating PCollections using the RowCoder:
> {code:java}
> try {
>  myRowCoder.encode(null, null);
>  } catch (IOException | NullPointerException e) {
>  // do nothing
> }
> {code}
> h3. Context:
> I've only encountered this during development with the direct runner.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to