Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package org.elasticsearch.gradle.precommit
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.file.FileCollection
Expand Down Expand Up @@ -101,6 +102,11 @@ class PrecommitTasks {
signaturesURLs = project.forbiddenApis.signaturesURLs +
[ getClass().getResource('/forbidden/es-server-signatures.txt') ]
}
// forbidden apis doesn't support Java 11, so stop at 10
String targetMajorVersion = (project.compilerJavaVersion.compareTo(JavaVersion.VERSION_1_10) > 0 ?
JavaVersion.VERSION_1_10 :
project.compilerJavaVersion).getMajorVersion()
targetCompatibility = Integer.parseInt(targetMajorVersion) >= 9 ?targetMajorVersion : "1.${targetMajorVersion}"
}
Task forbiddenApis = project.tasks.findByName('forbiddenApis')
forbiddenApis.group = "" // clear group, so this does not show up under verification tasks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void testArrayInitializers() {
"Object[] x = new Object[] {y, z, 1 + s, s + 'aaa'}; return x;");

assertEquals(4, objects.length);
assertEquals(new Integer(2), objects[0]);
assertEquals(Integer.valueOf(2), objects[0]);
assertEquals(new ArrayList(), objects[1]);
assertEquals("1aaa", objects[2]);
assertEquals("aaaaaa", objects[3]);
Expand Down Expand Up @@ -85,7 +85,7 @@ public void testListInitializers() {
list = (List)exec("int y = 2; List z = new ArrayList(); String s = 'aaa'; List x = [y, z, 1 + s, s + 'aaa']; return x;");

assertEquals(4, list.size());
assertEquals(new Integer(2), list.get(0));
assertEquals(Integer.valueOf(2), list.get(0));
assertEquals(new ArrayList(), list.get(1));
assertEquals("1aaa", list.get(2));
assertEquals("aaaaaa", list.get(3));
Expand All @@ -100,15 +100,15 @@ public void testMapInitializers() {
map = (Map)exec("[5 : 7, -1 : 14]");

assertEquals(2, map.size());
assertEquals(new Integer(7), map.get(5));
assertEquals(new Integer(14), map.get(-1));
assertEquals(Integer.valueOf(7), map.get(5));
assertEquals(Integer.valueOf(14), map.get(-1));

map = (Map)exec("int y = 2; int z = 3; Map x = [y*z : y + z, y - z : y, z : z]; return x;");

assertEquals(3, map.size());
assertEquals(new Integer(5), map.get(6));
assertEquals(new Integer(2), map.get(-1));
assertEquals(new Integer(3), map.get(3));
assertEquals(Integer.valueOf(5), map.get(6));
assertEquals(Integer.valueOf(2), map.get(-1));
assertEquals(Integer.valueOf(3), map.get(3));

map = (Map)exec("int y = 2; List z = new ArrayList(); String s = 'aaa';" +
"def x = [y : z, 1 + s : s + 'aaa']; return x;");
Expand Down Expand Up @@ -139,7 +139,7 @@ public void testCrazyInitializer() {
list3.add(9);

assertEquals(3, map.size());
assertEquals(new Integer(5), map.get(6));
assertEquals(Integer.valueOf(5), map.get(6));
assertEquals(list2, map.get("s"));
assertEquals(list3, map.get(3));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.elasticsearch.common.inject.matcher;

import org.elasticsearch.common.SuppressForbidden;

import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down Expand Up @@ -327,7 +329,9 @@ public String toString() {
return "inPackage(" + targetPackage.getName() + ")";
}

@SuppressForbidden(reason = "ClassLoader.getDefinedPackage not available yet")
public Object readResolve() {
// TODO minJava >= 9 : use ClassLoader.getDefinedPackage and remove @SuppressForbidden
return inPackage(Package.getPackage(packageName));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testParseFromXContent() throws IOException {
Float floatRep = randomFloat();
Number value = intValue;
if (randomBoolean()) {
value = new Float(floatRep += intValue);
value = Float.valueOf(floatRep += intValue);
}
XContentBuilder json = jsonBuilder().startObject()
.field(Fuzziness.X_FIELD_NAME, randomBoolean() ? value.toString() : value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public void testInheritContext() throws InterruptedException {
final CountDownLatch executed = new CountDownLatch(1);

threadContext.putHeader("foo", "bar");
final Integer one = new Integer(1);
final Integer one = Integer.valueOf(1);
threadContext.putTransient("foo", one);
EsThreadPoolExecutor executor =
EsExecutors.newFixed(getName(), pool, queue, EsExecutors.daemonThreadFactory("dummy"), threadContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void testStashContext() {
threadContext.putHeader("foo", "bar");
threadContext.putTransient("ctx.foo", 1);
assertEquals("bar", threadContext.getHeader("foo"));
assertEquals(new Integer(1), threadContext.getTransient("ctx.foo"));
assertEquals(Integer.valueOf(1), threadContext.getTransient("ctx.foo"));
assertEquals("1", threadContext.getHeader("default"));
try (ThreadContext.StoredContext ctx = threadContext.stashContext()) {
assertNull(threadContext.getHeader("foo"));
Expand All @@ -61,7 +61,7 @@ public void testStashAndMerge() {
threadContext.putHeader("foo", "bar");
threadContext.putTransient("ctx.foo", 1);
assertEquals("bar", threadContext.getHeader("foo"));
assertEquals(new Integer(1), threadContext.getTransient("ctx.foo"));
assertEquals(Integer.valueOf(1), threadContext.getTransient("ctx.foo"));
assertEquals("1", threadContext.getHeader("default"));
HashMap<String, String> toMerge = new HashMap<>();
toMerge.put("foo", "baz");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,10 @@ private static void setRandomCommonOptions(AbstractHighlighterBuilder highlightB
value = randomAlphaOfLengthBetween(1, 10);
break;
case 1:
value = new Integer(randomInt(1000));
value = Integer.valueOf(randomInt(1000));
break;
case 2:
value = new Boolean(randomBoolean());
value = Boolean.valueOf(randomBoolean());
break;
}
options.put(randomAlphaOfLengthBetween(1, 10), value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
public class EqualsHashCodeTestUtils {

private static Object[] someObjects = new Object[] { "some string", new Integer(1), new Double(1.0) };
private static Object[] someObjects = new Object[] { "some string", Integer.valueOf(1), Double.valueOf(1.0) };

/**
* A function that makes a copy of its input argument
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public void testResetScrollAfterSearchPhaseExecutionException() throws IOExcepti
assertThat(extractor.hasNext(), is(true));
output = extractor.next();
assertThat(output.isPresent(), is(true));
assertEquals(new Long(1400L), extractor.getLastTimestamp());
assertEquals(Long.valueOf(1400L), extractor.getLastTimestamp());
// A second failure is not tolerated
assertThat(extractor.hasNext(), is(true));
expectThrows(SearchPhaseExecutionException.class, extractor::next);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void testGetCalandarByJobId() throws Exception {
Long matchedCount = queryResult.stream().filter(
c -> c.getId().equals("foo calendar") || c.getId().equals("foo bar calendar") || c.getId().equals("cat foo calendar"))
.count();
assertEquals(new Long(3), matchedCount);
assertEquals(Long.valueOf(3), matchedCount);

queryResult = getCalendars("bar");
assertThat(queryResult, hasSize(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private TypeConverter() {

private static final long DAY_IN_MILLIS = 60 * 60 * 24;
private static final Map<Class<?>, JDBCType> javaToJDBC;

static {
Map<Class<?>, JDBCType> aMap = Arrays.stream(DataType.values())
.filter(dataType -> dataType.javaClass() != null
Expand Down Expand Up @@ -119,7 +119,7 @@ private static <T> T dateTimeConvert(Long millis, Calendar c, Function<Calendar,
c.setTimeInMillis(initial);
}
}

static long convertFromCalendarToUTC(long value, Calendar cal) {
if (cal == null) {
return value;
Expand All @@ -142,15 +142,15 @@ static <T> T convert(Object val, JDBCType columnType, Class<T> type) throws SQLE
if (type == null) {
return (T) convert(val, columnType);
}

if (type.isInstance(val)) {
try {
return type.cast(val);
} catch (ClassCastException cce) {
throw new SQLDataException("Unable to convert " + val.getClass().getName() + " to " + columnType, cce);
}
}

if (type == String.class) {
return (T) asString(convert(val, columnType));
}
Expand Down Expand Up @@ -276,16 +276,16 @@ static boolean isSigned(JDBCType jdbcType) throws SQLException {
}
return dataType.isSigned();
}


static JDBCType fromJavaToJDBC(Class<?> clazz) throws SQLException {
for (Entry<Class<?>, JDBCType> e : javaToJDBC.entrySet()) {
// java.util.Calendar from {@code javaToJDBC} is an abstract class and this method can be used with concrete classes as well
if (e.getKey().isAssignableFrom(clazz)) {
return e.getValue();
}
}

throw new SQLFeatureNotSupportedException("Objects of type " + clazz.getName() + " are not supported");
}

Expand Down Expand Up @@ -432,7 +432,7 @@ private static Float asFloat(Object val, JDBCType columnType) throws SQLExceptio
case REAL:
case FLOAT:
case DOUBLE:
return new Float(((Number) val).doubleValue());
return Float.valueOf((((float) ((Number) val).doubleValue())));
default:
}

Expand All @@ -451,7 +451,7 @@ private static Double asDouble(Object val, JDBCType columnType) throws SQLExcept
case REAL:
case FLOAT:
case DOUBLE:
return new Double(((Number) val).doubleValue());
return Double.valueOf(((Number) val).doubleValue());
default:
}

Expand Down Expand Up @@ -539,4 +539,4 @@ private static long safeToLong(double x) throws SQLException {
}
return Math.round(x);
}
}
}
Loading