avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomwh...@apache.org
Subject svn commit: r1724591 - in /avro/branches/branch-1.8: ./ lang/java/ lang/java/avro/ lang/java/avro/src/main/java/org/apache/avro/ lang/java/avro/src/main/resources/ lang/java/guava/ lang/java/mapred/ lang/java/tools/src/main/resources/META-INF/
Date Thu, 14 Jan 2016 11:39:21 GMT
Author: tomwhite
Date: Thu Jan 14 11:39:21 2016
New Revision: 1724591

URL: http://svn.apache.org/viewvc?rev=1724591&view=rev
Log:
AVRO-1781: Use Guava for a thread-safe weak identity cache.

Added:
    avro/branches/branch-1.8/lang/java/avro/src/main/resources/
      - copied from r1724473, avro/trunk/lang/java/avro/src/main/resources/
    avro/branches/branch-1.8/lang/java/guava/
      - copied from r1724473, avro/trunk/lang/java/guava/
Modified:
    avro/branches/branch-1.8/CHANGES.txt
    avro/branches/branch-1.8/lang/java/avro/pom.xml
    avro/branches/branch-1.8/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java
    avro/branches/branch-1.8/lang/java/guava/pom.xml
    avro/branches/branch-1.8/lang/java/mapred/pom.xml
    avro/branches/branch-1.8/lang/java/pom.xml
    avro/branches/branch-1.8/lang/java/tools/src/main/resources/META-INF/LICENSE

Modified: avro/branches/branch-1.8/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.8/CHANGES.txt?rev=1724591&r1=1724590&r2=1724591&view=diff
==============================================================================
--- avro/branches/branch-1.8/CHANGES.txt (original)
+++ avro/branches/branch-1.8/CHANGES.txt Thu Jan 14 11:39:21 2016
@@ -247,6 +247,9 @@ Avro 1.8.0 (15 December 2015)
     AVRO-1779. Avro docs convenience artifact missing LICENSE/NOTICE.
     (blue via tomwhite)
 
+    AVRO-1781. Java: Fix Schema.parse thread safety bug introduced by logical
+    types. (blue)
+
     AVRO-1782. Ruby: Fix unit test failures in new versions of Ruby. (martinkl)
 
 Avro 1.7.7 (23 July 2014)

Modified: avro/branches/branch-1.8/lang/java/avro/pom.xml
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.8/lang/java/avro/pom.xml?rev=1724591&r1=1724590&r2=1724591&view=diff
==============================================================================
--- avro/branches/branch-1.8/lang/java/avro/pom.xml (original)
+++ avro/branches/branch-1.8/lang/java/avro/pom.xml Thu Jan 14 11:39:21 2016
@@ -84,6 +84,30 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <artifactSet>
+                <includes>
+                  <include>org.apache.avro:avro-guava-dependencies</include>
+                </includes>
+              </artifactSet>
+              <relocations>
+                <relocation>
+                  <pattern>com.google.common</pattern>
+                  <shadedPattern>avro.shaded.com.google.common</shadedPattern>
+                </relocation>
+              </relocations>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 
@@ -140,6 +164,11 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.avro</groupId>
+      <artifactId>avro-guava-dependencies</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
       <groupId>org.codehaus.jackson</groupId>
       <artifactId>jackson-core-asl</artifactId>
     </dependency>

Modified: avro/branches/branch-1.8/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.8/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java?rev=1724591&r1=1724590&r2=1724591&view=diff
==============================================================================
--- avro/branches/branch-1.8/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java
(original)
+++ avro/branches/branch-1.8/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java
Thu Jan 14 11:39:21 2016
@@ -20,12 +20,14 @@ package org.apache.avro;
 
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import org.apache.avro.util.WeakIdentityHashMap;
+import com.google.common.base.Optional;
+import com.google.common.collect.MapMaker;
 
 public class LogicalTypes {
 
-  private static final Map<Schema, LogicalType> CACHE =
-      new WeakIdentityHashMap<Schema, LogicalType>();
+  private static final Map<Schema, Optional<LogicalType>> CACHE = new MapMaker()
+      .weakKeys()
+      .makeMap();
 
   public interface LogicalTypeFactory {
     LogicalType fromSchema(Schema schema);
@@ -53,13 +55,13 @@ public class LogicalTypes {
 
   public static LogicalType fromSchemaIgnoreInvalid(Schema schema) {
     if (CACHE.containsKey(schema)) {
-      return CACHE.get(schema);
+      return CACHE.get(schema).orNull();
     }
 
     LogicalType logicalType = fromSchemaImpl(schema, false);
 
     // add to the cache, even if it is null
-    CACHE.put(schema, logicalType);
+    CACHE.put(schema, Optional.fromNullable(logicalType));
 
     return logicalType;
   }

Modified: avro/branches/branch-1.8/lang/java/guava/pom.xml
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.8/lang/java/guava/pom.xml?rev=1724591&r1=1724473&r2=1724591&view=diff
==============================================================================
--- avro/branches/branch-1.8/lang/java/guava/pom.xml (original)
+++ avro/branches/branch-1.8/lang/java/guava/pom.xml Thu Jan 14 11:39:21 2016
@@ -23,7 +23,7 @@
   <parent>
     <artifactId>avro-parent</artifactId>
     <groupId>org.apache.avro</groupId>
-    <version>1.9.0-SNAPSHOT</version>
+    <version>1.8.0</version>
     <relativePath>../</relativePath>
   </parent>
 

Modified: avro/branches/branch-1.8/lang/java/mapred/pom.xml
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.8/lang/java/mapred/pom.xml?rev=1724591&r1=1724590&r2=1724591&view=diff
==============================================================================
--- avro/branches/branch-1.8/lang/java/mapred/pom.xml (original)
+++ avro/branches/branch-1.8/lang/java/mapred/pom.xml Thu Jan 14 11:39:21 2016
@@ -109,6 +109,33 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <version>1.4.1</version>
+        <executions>
+          <execution>
+            <id>enforce-banned-dependencies</id>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <bannedDependencies>
+                  <!-- Ban all versions of Guava other than 11.0.2 that Hadoop uses -->
+                  <excludes>
+                    <exclude>com.google.guava:guava</exclude>
+                  </excludes>
+                  <includes>
+                    <include>com.google.guava:guava:11.0.2</include>
+                  </includes>
+                </bannedDependencies>
+              </rules>
+              <fail>true</fail>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 

Modified: avro/branches/branch-1.8/lang/java/pom.xml
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.8/lang/java/pom.xml?rev=1724591&r1=1724590&r2=1724591&view=diff
==============================================================================
--- avro/branches/branch-1.8/lang/java/pom.xml (original)
+++ avro/branches/branch-1.8/lang/java/pom.xml Thu Jan 14 11:39:21 2016
@@ -69,6 +69,8 @@
     <hamcrest.version>1.3</hamcrest.version>
     <commons-httpclient.version>3.1</commons-httpclient.version>
     <joda.version>2.7</joda.version>
+    <!-- This Guava version should match Hadoop's Guava version. See AVRO-1781. -->
+    <guava.version>11.0.2</guava.version>
     <findbugs-annotations.version>1.3.9-1</findbugs-annotations.version>
 
     <!-- version properties for plugins -->
@@ -90,6 +92,7 @@
   </properties>
 
   <modules>
+    <module>guava</module>
     <module>avro</module>
     <module>compiler</module>
     <module>maven-plugin</module>

Modified: avro/branches/branch-1.8/lang/java/tools/src/main/resources/META-INF/LICENSE
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.8/lang/java/tools/src/main/resources/META-INF/LICENSE?rev=1724591&r1=1724590&r2=1724591&view=diff
==============================================================================
--- avro/branches/branch-1.8/lang/java/tools/src/main/resources/META-INF/LICENSE (original)
+++ avro/branches/branch-1.8/lang/java/tools/src/main/resources/META-INF/LICENSE Thu Jan 14
11:39:21 2016
@@ -1118,3 +1118,10 @@ All rights reserved.
 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 | OF CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT OF OR IN CONNECTION
 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+----------------------------------------------------------------------
+License for Guava classes included in this binary artifact:
+
+Copyright: 2006-2015 The Guava Authors
+License: http://www.apache.org/licenses/LICENSE-2.0 (see above)
+



Mime
View raw message