From commits-return-2423-apmail-avro-commits-archive=avro.apache.org@avro.apache.org Thu Nov 8 16:01:58 2018 Return-Path: X-Original-To: apmail-avro-commits-archive@www.apache.org Delivered-To: apmail-avro-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A08BC18246 for ; Thu, 8 Nov 2018 16:01:58 +0000 (UTC) Received: (qmail 28554 invoked by uid 500); 8 Nov 2018 16:01:58 -0000 Delivered-To: apmail-avro-commits-archive@avro.apache.org Received: (qmail 28507 invoked by uid 500); 8 Nov 2018 16:01:58 -0000 Mailing-List: contact commits-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@avro.apache.org Delivered-To: mailing list commits@avro.apache.org Received: (qmail 28498 invoked by uid 99); 8 Nov 2018 16:01:58 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Nov 2018 16:01:58 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id E166D8519C; Thu, 8 Nov 2018 16:01:57 +0000 (UTC) Date: Thu, 08 Nov 2018 16:01:57 +0000 To: "commits@avro.apache.org" Subject: [avro] branch master updated: [AVRO-2228] Bump Apache Velocity to 2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <154169291781.374.14697355404027073547@gitbox.apache.org> From: dkulp@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: avro X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: aa5860fc355d7d44c3d567fdb1fb2d20ad474cc0 X-Git-Newrev: c4386ad21f16b4fdd761eeb5ac4332f6221aac3f X-Git-Rev: c4386ad21f16b4fdd761eeb5ac4332f6221aac3f X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. dkulp pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/avro.git The following commit(s) were added to refs/heads/master by this push: new c4386ad [AVRO-2228] Bump Apache Velocity to 2.0 c4386ad is described below commit c4386ad21f16b4fdd761eeb5ac4332f6221aac3f Author: Fokko Driesprong AuthorDate: Mon Sep 24 10:07:03 2018 -0700 [AVRO-2228] Bump Apache Velocity to 2.0 - Remove Slf4jLogChute since 2.0 uses SLF4J itself - Update $velocityHasNext to $foreach.hasNext because of deprecation - Update $velocityCount to $foreach.count because of deprecation - 2.0 does not depend on apache-common collections anymore which used to be an old version with security issues --- lang/java/compiler/pom.xml | 2 +- .../avro/compiler/specific/SpecificCompiler.java | 104 +++------------------ .../specific/templates/java/classic/enum.vm | 2 +- .../specific/templates/java/classic/protocol.vm | 4 +- .../specific/templates/java/classic/record.vm | 2 +- lang/java/ipc/pom.xml | 3 +- lang/java/pom.xml | 4 +- 7 files changed, 20 insertions(+), 101 deletions(-) diff --git a/lang/java/compiler/pom.xml b/lang/java/compiler/pom.xml index d236df0..7bee6e3 100644 --- a/lang/java/compiler/pom.xml +++ b/lang/java/compiler/pom.xml @@ -163,7 +163,7 @@ org.apache.velocity - velocity + velocity-engine-core com.fasterxml.jackson.core diff --git a/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java b/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java index aa7c5c3..5ee2bdc 100644 --- a/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java +++ b/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java @@ -52,8 +52,6 @@ import org.apache.avro.generic.GenericData.StringType; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; -import org.apache.velocity.runtime.RuntimeServices; -import org.apache.velocity.runtime.log.LogChute; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -271,8 +269,6 @@ public class SpecificCompiler { return dateTimeLogicalTypeImplementation; } - private static String logChuteName = null; - private void initializeVelocity() { this.velocityEngine = new VelocityEngine(); @@ -286,17 +282,9 @@ public class SpecificCompiler { velocityEngine.addProperty("file.resource.loader.path", "/, ."); velocityEngine.setProperty("runtime.references.strict", true); - // try to use Slf4jLogChute, but if we can't use the null one. - if (null == logChuteName) { - // multiple threads can get here concurrently, but that's ok. - try { - new Slf4jLogChute(); - logChuteName = Slf4jLogChute.class.getName(); - } catch (Exception e) { - logChuteName = "org.apache.velocity.runtime.log.NullLogChute"; - } - } - velocityEngine.setProperty("runtime.log.logsystem.class", logChuteName); + // Set whitespace gobbling to Backward Compatible (BC) + // http://velocity.apache.org/engine/2.0/developer-guide.html#space-gobbling + velocityEngine.setProperty("space.gobbling", "bc"); } private void initializeSpecificData() { @@ -490,13 +478,15 @@ public class SpecificCompiler { this.createAllArgsConstructor = calcAllArgConstructorParameterUnits(record) <= MAX_FIELD_PARAMETER_UNIT_COUNT; - if (!this.createAllArgsConstructor) - new Slf4jLogChute().log(LogChute.WARN_ID, "Record '" + record.getFullName() + - "' contains more than " + MAX_FIELD_PARAMETER_UNIT_COUNT + - " parameters which exceeds the JVM " + - "spec for the number of permitted constructor arguments. Clients must " + - "rely on the builder pattern to create objects instead. For more info " + - "see JIRA ticket AVRO-1642."); + if (!this.createAllArgsConstructor) { + Logger logger = LoggerFactory.getLogger(SpecificCompiler.class); + logger.warn("Record '" + record.getFullName() + + "' contains more than " + MAX_FIELD_PARAMETER_UNIT_COUNT + + " parameters which exceeds the JVM " + + "spec for the number of permitted constructor arguments. Clients must " + + "rely on the builder pattern to create objects instead. For more info " + + "see JIRA ticket AVRO-1642."); + } } OutputFile compile(Schema schema) { @@ -1055,75 +1045,6 @@ public class SpecificCompiler { compileProtocol(new File(args[0]), new File(args[1])); } - public static final class Slf4jLogChute implements LogChute { - private Logger logger = LoggerFactory.getLogger("AvroVelocityLogChute"); - @Override - public void init(RuntimeServices rs) throws Exception { - // nothing to do - } - - @Override - public void log(int level, String message) { - switch (level) { - case LogChute.DEBUG_ID: - logger.debug(message); - break; - case LogChute.TRACE_ID: - logger.trace(message); - break; - case LogChute.WARN_ID: - logger.warn(message); - break; - case LogChute.ERROR_ID: - logger.error(message); - break; - default: - case LogChute.INFO_ID: - logger.info(message); - break; - } - } - - @Override - public void log(int level, String message, Throwable t) { - switch (level) { - case LogChute.DEBUG_ID: - logger.debug(message, t); - break; - case LogChute.TRACE_ID: - logger.trace(message, t); - break; - case LogChute.WARN_ID: - logger.warn(message, t); - break; - case LogChute.ERROR_ID: - logger.error(message, t); - break; - default: - case LogChute.INFO_ID: - logger.info(message, t); - break; - } - } - - @Override - public boolean isLevelEnabled(int level) { - switch (level) { - case LogChute.DEBUG_ID: - return logger.isDebugEnabled(); - case LogChute.TRACE_ID: - return logger.isTraceEnabled(); - case LogChute.WARN_ID: - return logger.isWarnEnabled(); - case LogChute.ERROR_ID: - return logger.isErrorEnabled(); - default: - case LogChute.INFO_ID: - return logger.isInfoEnabled(); - } - } - } - /** Sets character encoding for generated java file * @param outputCharacterEncoding Character encoding for output files (defaults to system encoding) */ @@ -1131,4 +1052,3 @@ public class SpecificCompiler { this.outputCharacterEncoding = outputCharacterEncoding; } } - diff --git a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/enum.vm b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/enum.vm index 92d0c05..07e6746 100644 --- a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/enum.vm +++ b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/enum.vm @@ -26,7 +26,7 @@ package $schema.getNamespace(); #end @org.apache.avro.specific.AvroGenerated public enum ${this.mangle($schema.getName())} { - #foreach ($symbol in ${schema.getEnumSymbols()})${this.mangle($symbol)}#if ($velocityHasNext), #end#end + #foreach ($symbol in ${schema.getEnumSymbols()})${this.mangle($symbol)}#if ($foreach.hasNext), #end#end ; public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("${this.javaEscape($schema.toString())}"); public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } diff --git a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/protocol.vm b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/protocol.vm index 068bd75..ca5492d 100644 --- a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/protocol.vm +++ b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/protocol.vm @@ -47,7 +47,7 @@ public interface $this.mangle($protocol.getName()) { #if ($message.isOneWay())void#else${this.javaUnbox($response)}#end ${this.mangle($name)}(## #foreach ($p in $message.getRequest().getFields())## -#* *#${this.javaUnbox($p.schema())} ${this.mangle($p.name())}#if ($velocityHasNext), #end +#* *#${this.javaUnbox($p.schema())} ${this.mangle($p.name())}#if ($foreach.hasNext), #end #end )#if (! $message.isOneWay()) throws org.apache.avro.AvroRemoteException## @@ -84,7 +84,7 @@ public interface $this.mangle($protocol.getName()) { */ void ${this.mangle($name)}(## #foreach ($p in $message.getRequest().getFields())## -#* *#${this.javaUnbox($p.schema())} ${this.mangle($p.name())}#if ($velocityHasNext), #end +#* *#${this.javaUnbox($p.schema())} ${this.mangle($p.name())}#if ($foreach.hasNext), #end #end #if ($message.getRequest().getFields().size() > 0), #end org.apache.avro.ipc.Callback<${this.javaType($response)}> callback) throws java.io.IOException; diff --git a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm index 5a59a6e..bc0c1d4 100644 --- a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm +++ b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm @@ -133,7 +133,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or #end #end */ - public ${this.mangle($schema.getName())}(#foreach($field in $schema.getFields())${this.javaType($field.schema())} ${this.mangle($field.name())}#if($velocityCount < $schema.getFields().size()), #end#end) { + public ${this.mangle($schema.getName())}(#foreach($field in $schema.getFields())${this.javaType($field.schema())} ${this.mangle($field.name())}#if($foreach.count < $schema.getFields().size()), #end#end) { #foreach ($field in $schema.getFields()) this.${this.mangle($field.name())} = ${this.mangle($field.name())}; #end diff --git a/lang/java/ipc/pom.xml b/lang/java/ipc/pom.xml index 4358cba..d0767a8 100644 --- a/lang/java/ipc/pom.xml +++ b/lang/java/ipc/pom.xml @@ -136,10 +136,9 @@ org.apache.velocity - velocity + velocity-engine-core - diff --git a/lang/java/pom.xml b/lang/java/pom.xml index eae6899..3b5f67f 100644 --- a/lang/java/pom.xml +++ b/lang/java/pom.xml @@ -49,7 +49,7 @@ 0.9.3 1.7.25 1.1.7.2 - 1.7 + 2.0 2.0.11 1.10.0 1.3.1 @@ -423,7 +423,7 @@ org.apache.velocity - velocity + velocity-engine-core ${velocity.version}