diff options
author | jonmv <venstad@gmail.com> | 2023-01-27 18:03:07 +0100 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2023-01-27 18:03:07 +0100 |
commit | 5aa00fffe0b3ebae4f0252031b6ad9214b4d6ff8 (patch) | |
tree | 762e4df9d59ba7ad4a2b3928b35fbd3ce2a23103 /vespajlib/src | |
parent | 1770e53c93134b268f0fac6239bc84b8f15688c4 (diff) |
Revert "Merge pull request #25770 from vespa-engine/jonmv/private-endpoints"
This reverts commit a3ae8f5b0ec3a7f2f3c9205289470dbb89e477ff, reversing
changes made to 6534f02466a8958513a8b8684cc2a4369fab7666.
Diffstat (limited to 'vespajlib/src')
-rw-r--r-- | vespajlib/src/main/java/ai/vespa/http/HttpURL.java | 2 | ||||
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/text/Utf8.java | 23 | ||||
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/yolean/Exceptions.java | 9 |
3 files changed, 12 insertions, 22 deletions
diff --git a/vespajlib/src/main/java/ai/vespa/http/HttpURL.java b/vespajlib/src/main/java/ai/vespa/http/HttpURL.java index ba1a8e08740..9641ea2a8fd 100644 --- a/vespajlib/src/main/java/ai/vespa/http/HttpURL.java +++ b/vespajlib/src/main/java/ai/vespa/http/HttpURL.java @@ -239,7 +239,7 @@ public class HttpURL { return parse(raw, HttpURL::requirePathSegment); } - /** Parses the given raw, normalized path string; this ignores whether the path is absolute or relative. */ + /** Parses the given raw, normalized path string; this ignores whether the path is absolute or relative.) */ public static Path parse(String raw, Consumer<String> validator) { Path path = new Path(null, 0, raw.endsWith("/"), segmentValidator(validator)); if (raw.startsWith("/")) raw = raw.substring(1); diff --git a/vespajlib/src/main/java/com/yahoo/text/Utf8.java b/vespajlib/src/main/java/com/yahoo/text/Utf8.java index 3a7ecaa727a..2a42cb5cdee 100644 --- a/vespajlib/src/main/java/com/yahoo/text/Utf8.java +++ b/vespajlib/src/main/java/com/yahoo/text/Utf8.java @@ -10,8 +10,7 @@ import java.nio.ReadOnlyBufferException; import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; import java.nio.charset.CodingErrorAction; - -import static java.nio.charset.StandardCharsets.UTF_8; +import java.nio.charset.StandardCharsets; /** * Utility class with functions for handling UTF-8 @@ -24,16 +23,16 @@ public final class Utf8 { private static final byte [] TRUE = {(byte) 't', (byte) 'r', (byte) 'u', (byte) 'e'}; private static final byte [] FALSE = {(byte) 'f', (byte) 'a', (byte) 'l', (byte) 's', (byte) 'e'}; - private static final byte[] LONG_MIN_VALUE_BYTES = String.valueOf(Long.MIN_VALUE).getBytes(UTF_8); + private static final byte[] LONG_MIN_VALUE_BYTES = String.valueOf(Long.MIN_VALUE).getBytes(StandardCharsets.UTF_8); /** Returns the Charset instance for UTF-8 */ public static Charset getCharset() { - return UTF_8; + return StandardCharsets.UTF_8; } /** To be used instead of String.String(byte[] bytes) */ public static String toStringStd(byte[] data) { - return new String(data, UTF_8); + return new String(data, StandardCharsets.UTF_8); } /** @@ -61,7 +60,7 @@ public final class Utf8 { * @return a decoded String */ public static String toString(ByteBuffer data) { - CharBuffer c = UTF_8.decode(data); + CharBuffer c = StandardCharsets.UTF_8.decode(data); return c.toString(); } @@ -69,7 +68,7 @@ public final class Utf8 { * Uses String.getBytes directly. */ public static byte[] toBytesStd(String str) { - return str.getBytes(UTF_8); + return str.getBytes(StandardCharsets.UTF_8); } /** @@ -113,7 +112,7 @@ public final class Utf8 { */ public static byte[] toBytes(String string) { // This is just wrapper for String::getBytes. Pre-Java 9 this had a more efficient approach for ASCII-only strings. - return string.getBytes(UTF_8); + return string.getBytes(StandardCharsets.UTF_8); } /** * Decode a UTF-8 string. @@ -123,7 +122,7 @@ public final class Utf8 { */ public static String toString(byte[] utf8) { // This is just wrapper for String::new. Pre-Java 9 this had a more efficient approach for ASCII-onlu strings. - return new String(utf8, UTF_8); + return new String(utf8, StandardCharsets.UTF_8); } /** @@ -139,7 +138,7 @@ public final class Utf8 { */ public static byte[] toBytes(String str, int offset, int length) { CharBuffer c = CharBuffer.wrap(str, offset, offset + length); - ByteBuffer b = UTF_8.encode(c); + ByteBuffer b = StandardCharsets.UTF_8.encode(c); byte[] result = new byte[b.remaining()]; b.get(result); return result; @@ -162,7 +161,7 @@ public final class Utf8 { */ public static int toBytes(String str, int srcOffset, int srcLen, byte[] dst, int dstOffset) { CharBuffer c = CharBuffer.wrap(str, srcOffset, srcOffset + srcLen); - ByteBuffer b = UTF_8.encode(c); + ByteBuffer b = StandardCharsets.UTF_8.encode(c); int encoded = b.remaining(); b.get(dst, dstOffset, encoded); return encoded; @@ -207,7 +206,7 @@ public final class Utf8 { * @see Utf8#toBytes(String, int, int, ByteBuffer, CharsetEncoder) */ public static CharsetEncoder getNewEncoder() { - return UTF_8.newEncoder().onMalformedInput(CodingErrorAction.REPLACE) + return StandardCharsets.UTF_8.newEncoder().onMalformedInput(CodingErrorAction.REPLACE) .onUnmappableCharacter(CodingErrorAction.REPLACE); } diff --git a/vespajlib/src/main/java/com/yahoo/yolean/Exceptions.java b/vespajlib/src/main/java/com/yahoo/yolean/Exceptions.java index 4f3f048eb0c..89b4e76368b 100644 --- a/vespajlib/src/main/java/com/yahoo/yolean/Exceptions.java +++ b/vespajlib/src/main/java/com/yahoo/yolean/Exceptions.java @@ -4,7 +4,6 @@ package com.yahoo.yolean; import java.io.IOException; import java.io.UncheckedIOException; import java.util.Optional; -import java.util.function.Function; /** * Helper methods for handling exceptions @@ -130,14 +129,6 @@ public class Exceptions { @FunctionalInterface public interface RunnableThrowingInterruptedException { void run() throws InterruptedException; } /** - * Wraps any IOException thrown from a function in an UncheckedIOException. - */ - public static <T, R> Function<T, R> uncheck(FunctionThrowingIOException<T, R> function) { - return t -> uncheck(() -> function.map(t)); - } - @FunctionalInterface public interface FunctionThrowingIOException<T, R> { R map(T t) throws IOException; } - - /** * Wraps any IOException thrown from a supplier in an UncheckedIOException. */ public static <T> T uncheck(SupplierThrowingIOException<T> supplier) { |