[Bug 902086] Review request: Elasticsearch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



https://bugzilla.redhat.com/show_bug.cgi?id=902086



--- Comment #86 from gil cattaneo <puntogil@xxxxxxxxx> ---
(In reply to jiri vanek from comment #82)
> After reformanting, this are differences between packed basae64 and included
> one.
> 
> --- Base64.java
> +++ Base64-es.java
> @@ -1,4 +1,3 @@
> -package net.iharder;
>  
>  /**
>   * <p>
> @@ -238,7 +237,7 @@
>      /**
>       * Preferred encoding.
>       */
> -    private final static String PREFERRED_ENCODING = "US-ASCII";
> +    public final static Charset PREFERRED_ENCODING =
> Charset.forName("US-ASCII");
>  
>      private final static byte WHITE_SPACE_ENC = -5; // Indicates white
> space in encoding
>      private final static byte EQUALS_SIGN_ENC = -1; // Indicates equals
> sign in encoding
> @@ -265,7 +264,6 @@
>      /**
>       * Translates a Base64 value to either its 6-bit reconstruction value
> or a
>       * negative number indicating some other meaning.
> -     *
>       */
>      private final static byte[] _STANDARD_DECODABET = {
>          -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal  0 -  8
> @@ -300,6 +298,7 @@
>          -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 231
> - 243
>          -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9 // Decimal 244 - 255
>      };
> +
>  
>      /* ********  U R L   S A F E   B A S E 6 4   A L P H A B E T  ********
> */
>      /**
> @@ -714,13 +713,7 @@
>          }   // end finally
>  
>          // Return value according to relevant encoding.
> -        try {
> -            return new String(baos.toByteArray(), PREFERRED_ENCODING);
> -        } // end try
> -        catch (java.io.UnsupportedEncodingException uue) {
> -            // Fall back to some Java default
> -            return new String(baos.toByteArray());
> -        }   // end catch
> +        return new String(baos.toByteArray(), PREFERRED_ENCODING);
>  
>      }   // end encode
>  
> @@ -852,12 +845,7 @@
>          byte[] encoded = encodeBytesToBytes(source, off, len, options);
>  
>          // Return value according to relevant encoding.
> -        try {
> -            return new String(encoded, PREFERRED_ENCODING);
> -        } // end try
> -        catch (java.io.UnsupportedEncodingException uue) {
> -            return new String(encoded);
> -        }   // end catch
> +        return new String(encoded, PREFERRED_ENCODING);
>  
>      }   // end encodeBytes
>  
> @@ -915,7 +903,7 @@
>  
>          if (off + len > source.length) {
>              throw new IllegalArgumentException(
> -                    String.format("Cannot have offset of %d and length of
> %d with array of length %d", off, len, source.length));
> +                    String.format(Locale.ROOT, "Cannot have offset of %d
> and length of %d with array of length %d", off, len, source.length));
>          }   // end if: off < 0
>  
>          // Compress?
> @@ -1052,11 +1040,11 @@
>              throw new NullPointerException("Destination array was null.");
>          }   // end if
>          if (srcOffset < 0 || srcOffset + 3 >= source.length) {
> -            throw new IllegalArgumentException(String.format(
> +            throw new IllegalArgumentException(String.format(Locale.ROOT,
>                      "Source array with length %d cannot have offset of %d
> and still process four bytes.", source.length, srcOffset));
>          }   // end if
>          if (destOffset < 0 || destOffset + 2 >= destination.length) {
> -            throw new IllegalArgumentException(String.format(
> +            throw new IllegalArgumentException(String.format(Locale.ROOT,
>                      "Destination array with length %d cannot have offset of
> %d and still store three bytes.", destination.length, destOffset));
>          }   // end if
>  
> @@ -1152,7 +1140,7 @@
>              throw new NullPointerException("Cannot decode null source
> array.");
>          }   // end if
>          if (off < 0 || off + len > source.length) {
> -            throw new IllegalArgumentException(String.format(
> +            throw new IllegalArgumentException(String.format(Locale.ROOT,
>                      "Source array with length %d cannot have offset of %d
> and process %d bytes.", source.length, off, len));
>          }   // end if
>  
> @@ -1190,14 +1178,25 @@
>  
>                          // If that was the equals sign, break out of 'for'
> loop
>                          if (source[i] == EQUALS_SIGN) {
> +                            // check if the equals sign is somewhere in
> between
> +                            if (i + 1 < len + off) {
> +                                throw new
> java.io.IOException(String.format(Locale.ROOT,
> +                                        "Found equals sign at position %d
> of the base64 string, not at the end", i));
> +                            }
>                              break;
>                          }   // end if: equals sign
> -                    }   // end if: quartet built
> +                    } // end if: quartet built
> +                    else {
> +                        if (source[i] == EQUALS_SIGN && len + off > i &&
> source[i + 1] != EQUALS_SIGN) {
> +                            throw new
> java.io.IOException(String.format(Locale.ROOT,
> +                                    "Found equals sign at position %d of
> the base64 string, not at the end", i));
> +                        } // enf if: equals sign and next character not as
> well
> +                    } // end else:
>                  }   // end if: equals sign or better
>              } // end if: white space, equals sign or better
>              else {
>                  // There's a bad input character in the Base64 stream.
> -                throw new java.io.IOException(String.format(
> +                throw new java.io.IOException(String.format(Locale.ROOT,
>                          "Bad Base64 input character decimal %d in array
> position %d", ((int) source[i]) & 0xFF, i));
>              }   // end else:
>          }   // each input character
> @@ -1237,13 +1236,7 @@
>              throw new NullPointerException("Input string was null.");
>          }   // end if
>  
> -        byte[] bytes;
> -        try {
> -            bytes = s.getBytes(PREFERRED_ENCODING);
> -        } // end try
> -        catch (java.io.UnsupportedEncodingException uee) {
> -            bytes = s.getBytes();
> -        }   // end catch
> +        byte[] bytes = s.getBytes(PREFERRED_ENCODING);
>          //</change>
>  
>          // Decode
> @@ -1276,7 +1269,7 @@
>  
>                  } // end try
>                  catch (java.io.IOException e) {
> -                    e.printStackTrace();
> +                    // e.printStackTrace();
>                      // Just return originally-decoded bytes
>                  } // end catch
>                  finally {
> @@ -1357,7 +1350,7 @@
>                      @Override
>                      public Class<?> resolveClass(java.io.ObjectStreamClass
> streamClass)
>                              throws java.io.IOException,
> ClassNotFoundException {
> -                        Class c = Class.forName(streamClass.getName(),
> false, loader);
> +                        Class<?> c = Class.forName(streamClass.getName(),
> false, loader);
>                          if (c == null) {
>                              return super.resolveClass(streamClass);
>                          } else {
> 
> 
> IMHO they should be upstreamed, but it is obviusly not ES way.  Looking to
> them, I would rather kept them bundled.
> 
i dont know if upstream use old newer or modified Base64
then you must open an fpc exception
http://fedoraproject.org/wiki/Packaging:No_Bundled_Libraries#Exceptions
http://fedoraproject.org/wiki/Packaging:No_Bundled_Libraries#Requirement_if_you_bundle
> Anyway jdk8 have standart base64 api, and taht should be used.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are always notified about changes to this product and component
_______________________________________________
package-review mailing list
package-review@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/package-review





[Index of Archives]     [Fedora Legacy]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]