aboutsummaryrefslogtreecommitdiffhomepage
path: root/java
diff options
context:
space:
mode:
authorGravatar Pradeep Gollakota <pradeep.gollakota@lithium.com>2016-03-18 23:06:14 -0700
committerGravatar Pradeep Gollakota <pradeep.gollakota@lithium.com>2016-03-18 23:06:14 -0700
commit4d98369f6d00dbdaa45ee2b91f1ec149a60ef905 (patch)
treeef0f0ec97cc34cd9cbd3947c2e83833c81c90b86 /java
parent5e933847cc9e7826f1a9ee8b3dc1df4960b1ea5d (diff)
Allow custom URLs for Any in JsonFormat
- Using custom URL for types in Any will no longer throw an InvalidProtocolBufferException in JsonFormat - Fixes #1128
Diffstat (limited to 'java')
-rw-r--r--java/util/src/main/java/com/google/protobuf/util/JsonFormat.java7
1 files changed, 3 insertions, 4 deletions
diff --git a/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java b/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
index d13ff0ed..c9a28c9e 100644
--- a/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
+++ b/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
@@ -951,16 +951,15 @@ public class JsonFormat {
}
}
- private static final String TYPE_URL_PREFIX = "type.googleapis.com";
-
+
private static String getTypeName(String typeUrl)
throws InvalidProtocolBufferException {
String[] parts = typeUrl.split("/");
- if (parts.length != 2 || !parts[0].equals(TYPE_URL_PREFIX)) {
+ if (parts.length == 1) {
throw new InvalidProtocolBufferException(
"Invalid type url found: " + typeUrl);
}
- return parts[1];
+ return parts[parts.length - 1];
}
private static class ParserImpl {