Skip to content

Commit

Permalink
Merge branch '2.18' into deser-lock
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Mar 28, 2024
2 parents 3bcdd55 + 588b21e commit a6de259
Show file tree
Hide file tree
Showing 148 changed files with 2,190 additions and 973 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@3ab4101902695724f9365a384f86c1074d94e18c # v3.24.7
uses: github/codeql-action/init@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@3ab4101902695724f9365a384f86c1074d94e18c # v3.24.7
uses: github/codeql-action/autobuild@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@3ab4101902695724f9365a384f86c1074d94e18c # v3.24.7
uses: github/codeql-action/analyze@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- "3.0"
- "2.18"
- "2.17"
paths-ignore:
- "README.md"
Expand All @@ -12,6 +13,7 @@ on:
branches:
- master
- "3.0"
- "2.18"
- "2.17"
paths-ignore:
- "README.md"
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<parent>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-base</artifactId>
<version>2.17.1-SNAPSHOT</version>
<version>2.18.0-SNAPSHOT</version>
</parent>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.1-SNAPSHOT</version>
<version>2.18.0-SNAPSHOT</version>
<name>jackson-databind</name>
<packaging>jar</packaging>
<description>General data-binding functionality for Jackson: works on core streaming API</description>
Expand Down Expand Up @@ -68,7 +68,7 @@
<version.powermock>2.0.9</version.powermock>

<!-- for Reproducible Builds -->
<project.build.outputTimestamp>2024-03-12T21:52:43Z</project.build.outputTimestamp>
<project.build.outputTimestamp>2024-02-27T01:47:51Z</project.build.outputTimestamp>
</properties>

<dependencies>
Expand Down
18 changes: 0 additions & 18 deletions src/test/java/com/fasterxml/jackson/databind/BaseMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,6 @@ public String toString() {
}
}

/*
/**********************************************************
/* Shared serializers
/**********************************************************
*/

@SuppressWarnings("serial")
public static class UpperCasingSerializer extends StdScalarSerializer<String>
{
public UpperCasingSerializer() { super(String.class); }

@Override
public void serialize(String value, JsonGenerator gen,
SerializerProvider provider) throws IOException {
gen.writeString(value.toUpperCase());
}
}

/*
/**********************************************************
/* Construction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
import java.util.Map;

import org.junit.Assert;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;
import com.fasterxml.jackson.databind.testutil.NoCheckSubTypeValidator;

import static org.junit.jupiter.api.Assertions.assertEquals;

// for [databind#827]
public class PolyMapWriter827Test extends BaseMapTest
public class PolyMapWriter827Test extends DatabindTestUtil
{
static class CustomKey {
String a;
Expand All @@ -30,9 +34,10 @@ public void serialize(CustomKey key, JsonGenerator jsonGenerator, SerializerProv
}
}

@Test
public void testPolyCustomKeySerializer() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = newJsonMapper();
mapper.activateDefaultTyping(NoCheckSubTypeValidator.instance,
ObjectMapper.DefaultTyping.NON_FINAL);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.fasterxml.jackson.databind.seq;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;

import static org.junit.jupiter.api.Assertions.*;

/**
* Tests to verify aspects of error recover for reading using
* iterator.
*/
public class ReadRecoveryTest extends BaseMapTest
public class ReadRecoveryTest extends DatabindTestUtil
{
static class Bean {
public int a, b;
Expand All @@ -20,8 +25,9 @@ static class Bean {
/**********************************************************
*/

private final ObjectMapper MAPPER = new ObjectMapper();
private final ObjectMapper MAPPER = newJsonMapper();

@Test
public void testRootBeans() throws Exception
{
final String JSON = a2q("{'a':3} {'x':5}");
Expand All @@ -46,6 +52,7 @@ public void testRootBeans() throws Exception
// for [databind#734]
// Simple test for verifying that basic recover works for a case of
// unknown structured value
@Test
public void testSimpleRootRecovery() throws Exception
{
final String JSON = a2q("{'a':3}{'a':27,'foo':[1,2],'b':{'x':3}} {'a':1,'b':2} ");
Expand Down Expand Up @@ -75,6 +82,7 @@ public void testSimpleRootRecovery() throws Exception
}

// Similar to "raw" root-level Object sequence, but in array
@Test
public void testSimpleArrayRecovery() throws Exception
{
final String JSON = a2q("[{'a':3},{'a':27,'foo':[1,2],'b':{'x':3}} ,{'a':1,'b':2} ]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

import java.util.List;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;

import static org.junit.jupiter.api.Assertions.*;

public class ReadTreesTest extends BaseMapTest
public class ReadTreesTest extends DatabindTestUtil
{
private final ObjectMapper MAPPER = newJsonMapper();

Expand All @@ -19,6 +24,7 @@ static class IdValue {
/**********************************************************
*/

@Test
public void testReadTreeSequence() throws Exception
{
final String INPUT = a2q(
Expand Down Expand Up @@ -59,6 +65,7 @@ public void testReadTreeSequence() throws Exception
/**********************************************************
*/

@Test
public void testReadPOJOHandleFail() throws Exception
{
final String INPUT = a2q(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
import java.io.*;
import java.util.*;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.type.TypeReference;

import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.MappingIterator;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;

import static org.junit.jupiter.api.Assertions.*;

@SuppressWarnings("resource")
public class ReadValuesTest extends BaseMapTest
public class ReadValuesTest extends DatabindTestUtil
{
static class Bean {
public int a;
Expand Down Expand Up @@ -44,6 +48,7 @@ private enum Source {

private final ObjectMapper MAPPER = newJsonMapper();

@Test
public void testRootBeans() throws Exception
{
for (Source src : Source.values()) {
Expand Down Expand Up @@ -111,6 +116,7 @@ private void _testRootBeans(Source srcType) throws Exception
it.close();
}

@Test
public void testRootBeansInArray() throws Exception
{
final String JSON = "[{\"a\":6}, {\"a\":-7}]";
Expand Down Expand Up @@ -140,6 +146,7 @@ public void testRootBeansInArray() throws Exception
assertEquals(4, set.iterator().next().a);
}

@Test
public void testRootMaps() throws Exception
{
final String JSON = "{\"a\":3}{\"a\":27} ";
Expand All @@ -164,6 +171,7 @@ public void testRootMaps() throws Exception
/**********************************************************
*/

@Test
public void testRootBeansWithParser() throws Exception
{
final String JSON = "{\"a\":3}{\"a\":27} ";
Expand All @@ -180,6 +188,7 @@ public void testRootBeansWithParser() throws Exception
assertFalse(it.hasNext());
}

@Test
public void testRootArraysWithParser() throws Exception
{
final String JSON = "[1][3]";
Expand All @@ -201,6 +210,7 @@ public void testRootArraysWithParser() throws Exception
assertFalse(it.hasNext());
}

@Test
public void testHasNextWithEndArray() throws Exception {
final String JSON = "[1,3]";
JsonParser jp = MAPPER.createParser(JSON);
Expand All @@ -221,6 +231,7 @@ public void testHasNextWithEndArray() throws Exception {
assertFalse(it.hasNext());
}

@Test
public void testHasNextWithEndArrayManagedParser() throws Exception {
final String JSON = "[1,3]";

Expand All @@ -241,6 +252,7 @@ public void testHasNextWithEndArrayManagedParser() throws Exception {
/**********************************************************
*/

@Test
public void testNonRootBeans() throws Exception
{
final String JSON = "{\"leaf\":[{\"a\":3},{\"a\":27}]}";
Expand All @@ -265,6 +277,7 @@ public void testNonRootBeans() throws Exception
jp.close();
}

@Test
public void testNonRootMapsWithParser() throws Exception
{
final String JSON = "[{\"a\":3},{\"a\":27}]";
Expand All @@ -290,6 +303,7 @@ public void testNonRootMapsWithParser() throws Exception
jp.close();
}

@Test
public void testNonRootMapsWithObjectReader() throws Exception
{
String JSON = "[{ \"hi\": \"ho\", \"neighbor\": \"Joe\" },\n"
Expand All @@ -309,26 +323,31 @@ public void testNonRootMapsWithObjectReader() throws Exception
assertFalse(iterator.hasNext());
}

@Test
public void testObjectReaderWithJsonParserFastDoubleParser() throws Exception
{
testObjectReaderWithFastDoubleParser(true);
}

@Test
public void testObjectReaderWithJsonReadFeatureFastDoubleParser() throws Exception
{
testObjectReaderWithFastDoubleParser(false);
}

@Test
public void testObjectReaderWithJsonParserFastFloatParser() throws Exception
{
testObjectReaderWithFastFloatParser(true);
}

@Test
public void testObjectReaderWithJsonReadFeatureFastFloatParser() throws Exception
{
testObjectReaderWithFastFloatParser(false);
}

@Test
public void testNonRootArraysUsingParser() throws Exception
{
final String JSON = "[[1],[3]]";
Expand All @@ -354,6 +373,7 @@ public void testNonRootArraysUsingParser() throws Exception
p.close();
}

@Test
public void testEmptyIterator() throws Exception
{
MappingIterator<Object> empty = MappingIterator.emptyIterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.io.StringWriter;
import java.util.*;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
Expand All @@ -14,8 +16,11 @@

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;

import static org.junit.jupiter.api.Assertions.*;

public class SequenceWriterTest extends BaseMapTest
public class SequenceWriterTest extends DatabindTestUtil
{
static class Bean {
public int a;
Expand Down Expand Up @@ -89,10 +94,11 @@ public void close() throws IOException {
/**********************************************************
*/

private final ObjectMapper MAPPER = new ObjectMapper();
private final ObjectMapper MAPPER = newJsonMapper();
private final ObjectWriter WRITER = MAPPER.writer()
.withRootValueSeparator("\n");

@Test
public void testSimpleNonArray() throws Exception
{
StringWriter strw = new StringWriter();
Expand Down Expand Up @@ -121,6 +127,7 @@ public void testSimpleNonArray() throws Exception
strw.toString());
}

@Test
public void testSimpleNonArrayNoSeparator() throws Exception
{
final String EXP = a2q("{'a':1}{'a':2}");
Expand Down Expand Up @@ -228,6 +235,7 @@ public void testSimpleCloseable() throws Exception
assertEquals(a2q("{'closed':false,'x':0}"), out.toString());
}

@Test
public void testWithExplicitType() throws Exception
{
ObjectWriter w = MAPPER.writer()
Expand Down
Loading

0 comments on commit a6de259

Please sign in to comment.