Skip to content

Commit

Permalink
Fixes wrt [core#1378]
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 3, 2025
1 parent db65f1f commit 6842224
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public T deserialize(JsonParser p, DeserializationContext ctxt)
while ((t = p.nextToken()) != JsonToken.END_ARRAY) {
String str;
if (t == JsonToken.VALUE_STRING) {
str = p.getText();
str = p.getString();
} else {
CharSequence cs = (CharSequence) ctxt.handleUnexpectedToken(getValueType(ctxt), p);
str = cs.toString();
Expand All @@ -186,24 +186,24 @@ public T deserialize(JsonParser p, DeserializationContext ctxt)
return finish(intermediate);
}

char[] chars = p.getTextCharacters();
if (p.getTextOffset() == 0 && p.getTextLength() == chars.length) {
char[] chars = p.getStringCharacters();
if (p.getStringOffset() == 0 && p.getStringLength() == chars.length) {
intermediate.addAll(chars);
} else {
int i = 0;
// first, copy in batches of BATCH_COPY_SIZE
if ((p.getTextLength() - i) >= BATCH_COPY_SIZE) {
if ((p.getStringLength() - i) >= BATCH_COPY_SIZE) {
char[] buf = new char[BATCH_COPY_SIZE];
do {
System.arraycopy(chars, p.getTextOffset() + i, buf, 0, BATCH_COPY_SIZE);
System.arraycopy(chars, p.getStringOffset() + i, buf, 0, BATCH_COPY_SIZE);
intermediate.addAll(buf);
i += BATCH_COPY_SIZE;
} while ((p.getTextLength() - i) >= BATCH_COPY_SIZE);
} while ((p.getStringLength() - i) >= BATCH_COPY_SIZE);
}
// and finally, copy the remainder.
if (p.getTextLength() > i) {
if (p.getStringLength() > i) {
char[] tail = Arrays.copyOfRange(
chars, p.getTextOffset() + i, p.getTextOffset() + p.getTextLength());
chars, p.getStringOffset() + i, p.getStringOffset() + p.getStringLength());
intermediate.addAll(tail);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public HostAndPort deserialize(JsonParser p, DeserializationContext ctxt)
if (hostNode == null || hostNode.isNull()) {
host = "";
} else {
host = hostNode.asText();
host = hostNode.asString();
}
JsonNode n = root.get("port");
if (n == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
import tools.jackson.databind.deser.std.StdDeserializer;
import tools.jackson.databind.jsontype.TypeDeserializer;
import tools.jackson.databind.type.LogicalType;
import tools.jackson.databind.type.TypeFactory;
import tools.jackson.databind.util.ClassUtil;
import tools.jackson.datatype.guava.deser.util.RangeFactory;
import tools.jackson.datatype.guava.deser.util.RangeHelper;

/**
* Jackson deserializer for a Guava {@link Range}.
*<p>
* TODO: I think it would make sense to reimplement this deserializer to
* TODO: I think it would make sense to re-implement this deserializer to
* use Delegating Deserializer, using a POJO as an intermediate form (properties
* could be of type {@link java.lang.Object})
* This would also also simplify the implementation a bit.
Expand Down Expand Up @@ -227,7 +226,7 @@ public Range<?> deserialize(JsonParser p, DeserializationContext ctxt)
private Range<?> deserializeRangeFromString(DeserializationContext context, JsonParser p)
throws JacksonException
{
String rangeInterval = p.getText();
String rangeInterval = p.getString();

if (rangeInterval.isEmpty()) {
return null;
Expand Down Expand Up @@ -272,7 +271,7 @@ private BoundType deserializeBoundType(DeserializationContext context, JsonParse
throws JacksonException
{
expect(context, JsonToken.VALUE_STRING, p.currentToken());
String name = p.getText();
String name = p.getString();
if (name == null) {
name = "";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package tools.jackson.datatype.guava.deser.table;

import java.io.IOException;

import tools.jackson.core.JacksonException;
import tools.jackson.core.JsonParser;
import tools.jackson.core.JsonToken;

import tools.jackson.databind.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static class LowerCasingDeserializer extends StdScalarDeserializer<String

@Override
public String deserialize(JsonParser p, DeserializationContext ctxt) {
return p.getText().toLowerCase();
return p.getString().toLowerCase();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public T deserialize(JsonParser p, DeserializationContext ctxt)
while ((t = p.nextToken()) != JsonToken.END_ARRAY) {
String str;
if (t == JsonToken.VALUE_STRING) {
str = p.getText();
str = p.getString();
} else {
CharSequence cs =
(CharSequence) ctxt.handleUnexpectedToken(getValueType(ctxt), p);
Expand All @@ -60,8 +60,8 @@ public T deserialize(JsonParser p, DeserializationContext ctxt)
return finish(intermediate);
}

char[] chars = p.getTextCharacters();
addAll(intermediate, chars, p.getTextOffset(), p.getTextLength());
char[] chars = p.getStringCharacters();
addAll(intermediate, chars, p.getStringOffset(), p.getStringLength());
return finish(intermediate);
}
}

0 comments on commit 6842224

Please sign in to comment.