You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by ie...@apache.org on 2018/12/26 17:32:04 UTC

[avro] branch master updated (b124940 -> fab3d40)

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

iemejia pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git.


    from b124940  AVRO-2218: Update thrift to version 0.11.0 and tukaani to version 1.8
     new a9ec22c  Use RoundingMode for BigDecimal to avoid deprecation warning (Java > 9)
     new fab3d40  AVRO-2288: Refactor OutputBuffer to not throw Exceptions

The 2 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.


Summary of changes:
 .../apache/avro/specific/TestSpecificLogicalTypes.java    | 15 ++++++++-------
 .../java/org.apache.avro.codegentest/CustomDecimal.java   |  3 ++-
 .../src/main/java/org/apache/trevni/OutputBuffer.java     |  8 ++++----
 3 files changed, 14 insertions(+), 12 deletions(-)


[avro] 02/02: AVRO-2288: Refactor OutputBuffer to not throw Exceptions

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

iemejia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git

commit fab3d4051c6bf5cacf6bd80895a72332ae5f362f
Author: Ismaël Mejía <ie...@gmail.com>
AuthorDate: Thu Dec 20 14:22:26 2018 +0100

    AVRO-2288: Refactor OutputBuffer to not throw Exceptions
    
    It aligns this way with its parent class
---
 .../trevni/core/src/main/java/org/apache/trevni/OutputBuffer.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lang/java/trevni/core/src/main/java/org/apache/trevni/OutputBuffer.java b/lang/java/trevni/core/src/main/java/org/apache/trevni/OutputBuffer.java
index 27e4f6a..e48dafd 100644
--- a/lang/java/trevni/core/src/main/java/org/apache/trevni/OutputBuffer.java
+++ b/lang/java/trevni/core/src/main/java/org/apache/trevni/OutputBuffer.java
@@ -92,18 +92,18 @@ class OutputBuffer extends ByteArrayOutputStream {
     write(bytes, 0, bytes.length);
   }
 
-  public void writeBytes(ByteBuffer bytes) throws IOException {
+  public void writeBytes(ByteBuffer bytes) {
     int pos = bytes.position();
     int start = bytes.arrayOffset() + pos;
     int len = bytes.limit() - pos;
     writeBytes(bytes.array(), start, len);
   }
 
-  public void writeBytes(byte[] bytes) throws IOException {
+  public void writeBytes(byte[] bytes) {
     writeBytes(bytes, 0, bytes.length);
   }
 
-  public void writeBytes(byte[] bytes, int start, int len) throws IOException {
+  public void writeBytes(byte[] bytes, int start, int len) {
     writeInt(len);
     write(bytes, start, len);
   }
@@ -140,7 +140,7 @@ class OutputBuffer extends ByteArrayOutputStream {
     count += 8;
   }
 
-  public void writeInt(int n) throws IOException {
+  public void writeInt(int n) {
     ensure(5);
     n = (n << 1) ^ (n >> 31);                     // move sign to low-order bit
     if ((n & ~0x7F) != 0) {


[avro] 01/02: Use RoundingMode for BigDecimal to avoid deprecation warning (Java > 9)

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

iemejia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git

commit a9ec22cce3c5d0bbde162dca99a96adf4584b429
Author: Ismaël Mejía <ie...@gmail.com>
AuthorDate: Thu Dec 20 14:21:16 2018 +0100

    Use RoundingMode for BigDecimal to avoid deprecation warning (Java > 9)
---
 .../apache/avro/specific/TestSpecificLogicalTypes.java    | 15 ++++++++-------
 .../java/org.apache.avro.codegentest/CustomDecimal.java   |  3 ++-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificLogicalTypes.java b/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificLogicalTypes.java
index 02bea73..ed64a77 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificLogicalTypes.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificLogicalTypes.java
@@ -24,6 +24,7 @@ import static org.hamcrest.Matchers.*;
 import java.io.File;
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatterBuilder;
 import java.time.temporal.ChronoField;
@@ -100,7 +101,7 @@ public class TestSpecificLogicalTypes {
         LocalDate.now(),
         LocalTime.now(),
         DateTime.now().withZone(DateTimeZone.UTC),
-        new BigDecimal(123.45f).setScale(2, BigDecimal.ROUND_HALF_DOWN)
+        new BigDecimal(123.45f).setScale(2, RoundingMode.HALF_DOWN)
     );
 
     File data = write(TestRecordWithLogicalTypes.getClassSchema(), record);
@@ -121,7 +122,7 @@ public class TestSpecificLogicalTypes {
         java.time.LocalDate.now(),
         java.time.LocalTime.now(),
         java.time.Instant.now(),
-        new BigDecimal(123.45f).setScale(2, BigDecimal.ROUND_HALF_DOWN)
+        new BigDecimal(123.45f).setScale(2, RoundingMode.HALF_DOWN)
     );
 
     File data = write(TestRecordWithJsr310LogicalTypes.getClassSchema(), record);
@@ -147,7 +148,7 @@ public class TestSpecificLogicalTypes {
             // for granularity less than one second second.
             new DateTime((System.currentTimeMillis() / 1000) * 1000,
                     ISOChronology.getInstance()).withZone(DateTimeZone.UTC),
-            new BigDecimal(123.45f).setScale(2, BigDecimal.ROUND_HALF_DOWN)
+            new BigDecimal(123.45f).setScale(2, RoundingMode.HALF_DOWN)
     );
 
     File data = write(TestRecordWithLogicalTypes.getClassSchema(), withJoda);
@@ -182,7 +183,7 @@ public class TestSpecificLogicalTypes {
             java.time.LocalDate.now(),
             java.time.LocalTime.now(),
             java.time.Instant.now(),
-            new BigDecimal(123.45f).setScale(2, BigDecimal.ROUND_HALF_DOWN)
+            new BigDecimal(123.45f).setScale(2, RoundingMode.HALF_DOWN)
     );
 
     File data = write(TestRecordWithJsr310LogicalTypes.getClassSchema(), withJsr310);
@@ -225,7 +226,7 @@ public class TestSpecificLogicalTypes {
         new TimestampConversion().toLong(
             DateTime.now().withZone(DateTimeZone.UTC), null, null),
         new Conversions.DecimalConversion().toBytes(
-            new BigDecimal(123.45f).setScale(2, BigDecimal.ROUND_HALF_DOWN), null,
+            new BigDecimal(123.45f).setScale(2, RoundingMode.HALF_DOWN), null,
             LogicalTypes.decimal(9, 2))
     );
 
@@ -241,7 +242,7 @@ public class TestSpecificLogicalTypes {
     LocalDate date = LocalDate.now();
     LocalTime time = LocalTime.now();
     DateTime timestamp = DateTime.now().withZone(DateTimeZone.UTC);
-    BigDecimal decimal = new BigDecimal(123.45f).setScale(2, BigDecimal.ROUND_HALF_DOWN);
+    BigDecimal decimal = new BigDecimal(123.45f).setScale(2, RoundingMode.HALF_DOWN);
 
     TestRecordWithoutLogicalTypes record = new TestRecordWithoutLogicalTypes(
         true,
@@ -282,7 +283,7 @@ public class TestSpecificLogicalTypes {
     LocalDate date = LocalDate.now();
     LocalTime time = LocalTime.now();
     DateTime timestamp = DateTime.now().withZone(DateTimeZone.UTC);
-    BigDecimal decimal = new BigDecimal(123.45f).setScale(2, BigDecimal.ROUND_HALF_DOWN);
+    BigDecimal decimal = new BigDecimal(123.45f).setScale(2, RoundingMode.HALF_DOWN);
 
     TestRecordWithLogicalTypes record = new TestRecordWithLogicalTypes(
         true,
diff --git a/lang/java/integration-test/test-custom-conversions/src/main/java/org.apache.avro.codegentest/CustomDecimal.java b/lang/java/integration-test/test-custom-conversions/src/main/java/org.apache.avro.codegentest/CustomDecimal.java
index 1d4f40c..3febe7a 100644
--- a/lang/java/integration-test/test-custom-conversions/src/main/java/org.apache.avro.codegentest/CustomDecimal.java
+++ b/lang/java/integration-test/test-custom-conversions/src/main/java/org.apache.avro.codegentest/CustomDecimal.java
@@ -20,6 +20,7 @@ package org.apache.avro.codegentest;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.math.RoundingMode;
 
 /**
  * Wraps a BigDecimal just to demonstrate that it is possible to use custom implementation classes with custom conversions.
@@ -35,7 +36,7 @@ public class CustomDecimal implements Comparable<CustomDecimal> {
     public byte[] toByteArray(int scale) {
         final BigDecimal correctlyScaledValue;
         if (scale != internalValue.scale()) {
-            correctlyScaledValue = internalValue.setScale(scale, BigDecimal.ROUND_HALF_UP);
+            correctlyScaledValue = internalValue.setScale(scale, RoundingMode.HALF_UP);
         } else {
             correctlyScaledValue = internalValue;
         }