You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by rs...@apache.org on 2020/05/29 12:12:09 UTC

[avro] branch revert-741-AVRO-2649 created (now 6233f47)

This is an automated email from the ASF dual-hosted git repository.

rskraba pushed a change to branch revert-741-AVRO-2649
in repository https://gitbox.apache.org/repos/asf/avro.git.


      at 6233f47  Revert "AVRO-2649 Made argument order non-enforceable avro-tools cli (#741)"

This branch includes the following new commits:

     new 6233f47  Revert "AVRO-2649 Made argument order non-enforceable avro-tools cli (#741)"

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[avro] 01/01: Revert "AVRO-2649 Made argument order non-enforceable avro-tools cli (#741)"

Posted by rs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rskraba pushed a commit to branch revert-741-AVRO-2649
in repository https://gitbox.apache.org/repos/asf/avro.git

commit 6233f475a7a26ca5e08e6d300d683accd3993bc6
Author: RyanSkraba <ry...@skraba.com>
AuthorDate: Fri May 29 14:11:58 2020 +0200

    Revert "AVRO-2649 Made argument order non-enforceable avro-tools cli (#741)"
    
    This reverts commit 7fd098a56064ece218c66ba1d2ad78bd358f6009.
---
 .../org/apache/avro/tool/SpecificCompilerTool.java | 21 ++++++++--------
 .../apache/avro/tool/TestSpecificCompilerTool.java | 28 ----------------------
 2 files changed, 10 insertions(+), 39 deletions(-)

diff --git a/lang/java/tools/src/main/java/org/apache/avro/tool/SpecificCompilerTool.java b/lang/java/tools/src/main/java/org/apache/avro/tool/SpecificCompilerTool.java
index e50af59..550294e 100644
--- a/lang/java/tools/src/main/java/org/apache/avro/tool/SpecificCompilerTool.java
+++ b/lang/java/tools/src/main/java/org/apache/avro/tool/SpecificCompilerTool.java
@@ -68,17 +68,16 @@ public class SpecificCompilerTool implements Tool {
     Optional<FieldVisibility> fieldVisibility = Optional.empty();
 
     int arg = 0;
-    int counter = 0;
 
-    if (args.contains("-encoding")) {
-      arg = args.indexOf("-encoding") + 1;
+    if ("-encoding".equals(args.get(arg))) {
+      arg++;
       encoding = Optional.of(args.get(arg));
-      counter = counter + 2;
+      arg++;
     }
 
-    if (args.contains("-string")) {
+    if ("-string".equals(args.get(arg))) {
       stringType = StringType.String;
-      counter = counter + 1;
+      arg++;
     }
 
     if ("-fieldVisibility".equals(args.get(arg))) {
@@ -94,15 +93,15 @@ public class SpecificCompilerTool implements Tool {
 
     if ("-bigDecimal".equalsIgnoreCase(args.get(arg))) {
       useLogicalDecimal = true;
-      counter = counter + 1;
+      arg++;
     }
 
-    if (args.contains("-templateDir")) {
-      arg = args.indexOf("-templateDir") + 1;
+    if ("-templateDir".equals(args.get(arg))) {
+      arg++;
       templateDir = Optional.of(args.get(arg));
-      counter = counter + 2;
+      arg++;
     }
-    arg = counter;
+
     String method = args.get(arg);
     List<File> inputs = new ArrayList<>();
     File output = new File(args.get(args.size() - 1));
diff --git a/lang/java/tools/src/test/java/org/apache/avro/tool/TestSpecificCompilerTool.java b/lang/java/tools/src/test/java/org/apache/avro/tool/TestSpecificCompilerTool.java
index b6c0070..c511d66 100644
--- a/lang/java/tools/src/test/java/org/apache/avro/tool/TestSpecificCompilerTool.java
+++ b/lang/java/tools/src/test/java/org/apache/avro/tool/TestSpecificCompilerTool.java
@@ -126,34 +126,6 @@ public class TestSpecificCompilerTool {
     assertFileMatch(TEST_EXPECTED_STRING_FIELDTEST, TEST_OUTPUT_STRING_FIELDTEST);
   }
 
-  @Test
-  public void testOrderingOfFlags() throws Exception {
-
-    // Order of Flags as per initial implementation
-    doCompile(new String[] { "-encoding", "UTF-8", "-string", "-bigDecimal", "schema",
-        TEST_INPUT_DIR.toString() + "/fieldtest.avsc", TEST_INPUT_DIR.toString() + "/fieldtest.avsc",
-        TEST_OUTPUT_STRING_DIR.getPath() });
-    assertFileMatch(TEST_EXPECTED_STRING_FIELDTEST, TEST_OUTPUT_STRING_FIELDTEST);
-
-    // Change order of encoding and string
-    doCompile(new String[] { "-string", "-encoding", "UTF-8", "-bigDecimal", "schema",
-        TEST_INPUT_DIR.toString() + "/fieldtest.avsc", TEST_INPUT_DIR.toString() + "/fieldtest.avsc",
-        TEST_OUTPUT_STRING_DIR.getPath() });
-    assertFileMatch(TEST_EXPECTED_STRING_FIELDTEST, TEST_OUTPUT_STRING_FIELDTEST);
-
-    // Change order of -string and -bigDecimal
-    doCompile(new String[] { "-bigDecimal", "-encoding", "UTF-8", "-string", "schema",
-        TEST_INPUT_DIR.toString() + "/fieldtest.avsc", TEST_INPUT_DIR.toString() + "/fieldtest.avsc",
-        TEST_OUTPUT_STRING_DIR.getPath() });
-    assertFileMatch(TEST_EXPECTED_STRING_FIELDTEST, TEST_OUTPUT_STRING_FIELDTEST);
-
-    // Keep encoding at the end
-    doCompile(new String[] { "-bigDecimal", "-string", "-encoding", "UTF-8", "schema",
-        TEST_INPUT_DIR.toString() + "/fieldtest.avsc", TEST_INPUT_DIR.toString() + "/fieldtest.avsc",
-        TEST_OUTPUT_STRING_DIR.getPath() });
-    assertFileMatch(TEST_EXPECTED_STRING_FIELDTEST, TEST_OUTPUT_STRING_FIELDTEST);
-  }
-
   // Runs the actual compiler tool with the given input args
   private void doCompile(String[] args) throws Exception {
     SpecificCompilerTool tool = new SpecificCompilerTool();