From 103e97d69d05fd005228ceffaa97ff61a80b551c Mon Sep 17 00:00:00 2001 From: gjoranv Date: Thu, 26 Apr 2018 14:45:27 +0200 Subject: Remove vespajlib:Util - Vespa no longer supports Java 6 or older. --- .../query/parser/UnicodePropertyDumpTestCase.java | 10 +----- .../treenet/rule/ComparisonCondition.java | 4 +-- .../treenet/rule/SetMembershipCondition.java | 2 -- .../storage/searcher/GetSearcherTestCase.java | 5 ++- .../src/main/java/com/yahoo/java7compat/Util.java | 37 ---------------------- .../test/java/com/yahoo/java7compat/UtilTest.java | 29 ----------------- 6 files changed, 4 insertions(+), 83 deletions(-) delete mode 100644 vespajlib/src/main/java/com/yahoo/java7compat/Util.java delete mode 100644 vespajlib/src/test/java/com/yahoo/java7compat/UtilTest.java diff --git a/container-search/src/test/java/com/yahoo/prelude/query/parser/UnicodePropertyDumpTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/parser/UnicodePropertyDumpTestCase.java index 4c07a0ca59a..55be36abd62 100644 --- a/container-search/src/test/java/com/yahoo/prelude/query/parser/UnicodePropertyDumpTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/query/parser/UnicodePropertyDumpTestCase.java @@ -7,7 +7,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; -import com.yahoo.java7compat.Util; import org.junit.Test; /** @@ -33,14 +32,7 @@ public class UnicodePropertyDumpTestCase { toCheck.flush(); final String result = toCheck.toString("UTF-8"); - String expected; - - if (Util.isJava7Compatible()) { - expected = "0000002e 0000 24\n000000c5 0002 1\n0001d7d3 0006 5\n"; - } else { - expected = "0000002e 0000 24\n000000c5 0002 1\n0001d7d3 0010 0\n"; - } - + String expected = "0000002e 0000 24\n000000c5 0002 1\n0001d7d3 0006 5\n"; assertEquals(expected, result); } } diff --git a/searchlib/src/main/java/com/yahoo/searchlib/treenet/rule/ComparisonCondition.java b/searchlib/src/main/java/com/yahoo/searchlib/treenet/rule/ComparisonCondition.java index af01c906f9a..174cf21d684 100755 --- a/searchlib/src/main/java/com/yahoo/searchlib/treenet/rule/ComparisonCondition.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/treenet/rule/ComparisonCondition.java @@ -1,8 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchlib.treenet.rule; -import com.yahoo.java7compat.Util; - /** * Represents a condition which comparing two values * @@ -34,6 +32,6 @@ public class ComparisonCondition extends Condition { @Override public String conditionToRankingExpression() { - return "< " + Util.toJava7String(rhs); + return "< " + String.valueOf(rhs); } } diff --git a/searchlib/src/main/java/com/yahoo/searchlib/treenet/rule/SetMembershipCondition.java b/searchlib/src/main/java/com/yahoo/searchlib/treenet/rule/SetMembershipCondition.java index 3decfe920e4..b10452a7b32 100755 --- a/searchlib/src/main/java/com/yahoo/searchlib/treenet/rule/SetMembershipCondition.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/treenet/rule/SetMembershipCondition.java @@ -1,8 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchlib.treenet.rule; -import com.yahoo.java7compat.Util; - import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java b/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java index 8da09bc78ad..2424ce596a3 100755 --- a/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java +++ b/vespaclient-container-plugin/src/test/java/com/yahoo/storage/searcher/GetSearcherTestCase.java @@ -15,7 +15,6 @@ import com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage; import com.yahoo.documentapi.messagebus.protocol.GetDocumentReply; import com.yahoo.feedapi.FeedContext; import com.yahoo.feedapi.MessagePropertyProcessor; -import com.yahoo.java7compat.Util; import com.yahoo.messagebus.Message; import com.yahoo.messagebus.routing.Route; import com.yahoo.prelude.templates.SearchRendererAdaptor; @@ -431,9 +430,9 @@ public class GetSearcherTestCase { "\n" + "\n" + "\n" + "\n", result); diff --git a/vespajlib/src/main/java/com/yahoo/java7compat/Util.java b/vespajlib/src/main/java/com/yahoo/java7compat/Util.java deleted file mode 100644 index a70688d7c3e..00000000000 --- a/vespajlib/src/main/java/com/yahoo/java7compat/Util.java +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.java7compat; - -/** - * @author baldersheim - * @since 5.2 - */ - -public class Util { - private static final int javaVersion = Integer.valueOf(System.getProperty("java.version").substring(2,3)); - public static boolean isJava7Compatible() { return javaVersion >= 7; } - /** - * Takes the double value and prints it in a way that is compliant with the way java7 prints them. - * This is due to java7 finally fixing the trailing zero problem - * @param d the double value - * @return string representation of the double value - */ - public static String toJava7String(double d) { - String s = String.valueOf(d); - if ( ! isJava7Compatible() ) { - s = nonJava7CompatibleString(s); - } - return s; - } - - static String nonJava7CompatibleString(String s) { - if ((s.length() >= 3) && s.contains(".")) { - int l = s.length(); - for(; l > 2 && (s.charAt(l-1) == '0') && (s.charAt(l-2) >= '0') && (s.charAt(l-1) <= '9'); l--); - if (l != s.length()) { - s = s.substring(0, l); - } - } - return s; - } - -} diff --git a/vespajlib/src/test/java/com/yahoo/java7compat/UtilTest.java b/vespajlib/src/test/java/com/yahoo/java7compat/UtilTest.java deleted file mode 100644 index b2be19494bf..00000000000 --- a/vespajlib/src/test/java/com/yahoo/java7compat/UtilTest.java +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.java7compat; - -import org.junit.Test; -import static org.junit.Assert.assertEquals; - -/** - * @author baldersheim - * @since 5.2 - */ - -public class UtilTest { - - @Test - public void requireJava7CompatibleDoublePrinting() { - if (Util.isJava7Compatible()) { - assertEquals("0.004", String.valueOf(0.0040)); - }else { - assertEquals("0.0040", String.valueOf(0.0040)); - } - assertEquals("0.004", Util.toJava7String(0.0040) ); - } - - @Test - public void nonCompatible() { - assertEquals(Util.nonJava7CompatibleString("0.0040"), "0.004"); - } - -} -- cgit v1.2.3