Skip to content

Commit

Permalink
java 8 compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mfussenegger committed Mar 31, 2015
1 parent 736f070 commit 5659580
Show file tree
Hide file tree
Showing 30 changed files with 240 additions and 129 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
language: java
jdk:
- openjdk7
- oraclejdk8

matrix:
allow_failures:
- jdk: oraclejdk8

sudo: false
env:
global:
Expand Down
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ configurations {
}



task release(dependsOn: 'distTar') << {
logger.info("released version: " + getVersion.version);
}
Expand Down
10 changes: 8 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ buildscript {
}

plugins {
id "com.github.kt3k.coveralls" version "2.3.1"
id "com.github.kt3k.coveralls" version "2.3.1"
}

allprojects {
apply plugin: 'idea'
apply plugin: 'findbugs'
apply plugin: 'jacoco'

tasks.withType(JavaCompile) {
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
}

jacoco {
toolVersion = "0.7.1.201405082137"
}
Expand All @@ -31,6 +36,8 @@ allprojects {
}
}



final testOutputs = [:].withDefault {[]}


Expand Down Expand Up @@ -114,7 +121,6 @@ task jacocoReport(type: JacocoReport) {
}

subprojects {

idea {
module {
iml {
Expand Down
2 changes: 1 addition & 1 deletion client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies {
compile 'org.apache.lucene:lucene-core:4.10.3'
compile 'org.apache.lucene:lucene-analyzers-common:4.10.3'


compile 'com.google.code.findbugs:annotations:3.0.0'
compile files(project(':core').sourceSets.shared.output.classesDir)
compile files(project(':sql').sourceSets.shared.output.classesDir)

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/io/crate/core/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public static String dottedToSqlPath(String dottedPath) {
}

/**
* Return the common ancestors of a list of fields.<br />
* A field is a string that can use the dotted-notation to indicate nesting.<br />
* Return the common ancestors of a list of fields.<br>
* A field is a string that can use the dotted-notation to indicate nesting.<br>
*
* <pre>
* fields: [ "a", "a.b", "b.c", "b.c.d"]
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/io/crate/types/DataTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ public class DataTypes {
private final static ESLogger logger = Loggers.getLogger(DataTypes.class);

/**
* While adding new types here, please aware the {@link io.crate.breaker.SizeEstimatorFactory}
* If you add types here make sure to update the SizeEstimatorFactory in the SQL module.
*/
@SuppressWarnings("JavadocReference")
public final static UndefinedType UNDEFINED = UndefinedType.INSTANCE;
public final static NotSupportedType NOT_SUPPORTED = NotSupportedType.INSTANCE;

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/io/crate/types/FixedWidthType.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ public interface FixedWidthType {
* https://blogs.oracle.com/jrose/entry/fixnums_in_the_vm
* http://www.javaworld.com/article/2077496/testing-debugging/java-tip-130--do-you-know-your-data-size-.html
*/
public int fixedSize();
int fixedSize();
}
1 change: 0 additions & 1 deletion sql/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ buildscript {
}
}


test {
// force run, see: http://gradle.1045684.n5.nabble.com/how-does-gradle-decide-when-to-run-tests-td3314172.html
outputs.upToDateWhen { false }
Expand Down
6 changes: 4 additions & 2 deletions sql/src/main/java/io/crate/action/sql/SQLBaseRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,21 @@
/**
* SQL requests can be made either as bulk operation or as single operation.
*
* The TransportActions {@link io.crate.action.sql.TransportSQLAction} and {@link io.crate.action.sql.TransportSQLBulkAction}
* The TransportActions TransportSQLAction TransportSQLBulkAction
* are responsible to execute them.
*
* In order to use the actions either send a
* {@link io.crate.action.sql.SQLRequest} or
* {@link SQLBulkRequest}
*
* to them using the {@link io.crate.action.sql.SQLAction} or {@link io.crate.action.sql.SQLBulkAction}
* to them using the SQLAction or SQLBulkAction
*
*
* this abstract base class provides the shared components
* {@link #stmt()}, {@link #creationTime()} and {@link #includeTypesOnResponse()}
* which both concrete classes use.
*
* (not using links for TransportSQLAction as they're not included for the client and would case an error under oraclejdk8)
*/
public abstract class SQLBaseRequest extends ActionRequest<SQLBaseRequest> {

Expand Down
2 changes: 1 addition & 1 deletion sql/src/main/java/io/crate/lucene/QueryBuilderHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public Query eq(String columnName, Object value) {
if (value == null) {
return Queries.newMatchNoDocsQuery();
}
return new TermQuery(new Term(columnName, value == true ? "T" : "F"));
return new TermQuery(new Term(columnName, (boolean)value ? "T" : "F"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public BytesRef evaluate(Input<Object>... args) {
assert args.length > 1;
assert args[0].value() != null;



Object[] values = new Object[args.length - 1];
for (int i = 0; i < args.length - 1; i++) {
if (args[i + 1].value() instanceof BytesRef) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

package io.crate.analyze;

import com.google.common.base.Joiner;
import io.crate.core.collections.StringObjectMaps;
import io.crate.metadata.ColumnIdent;
import io.crate.metadata.MetaDataModule;
Expand All @@ -40,6 +39,7 @@
import java.util.List;
import java.util.Map;

import static io.crate.testing.TestingHelpers.mapToSortedString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -222,14 +222,13 @@ public void testAddNewNestedColumnToObjectColumn() throws Exception {
assertThat(name.dataType(), is("string"));

Map<String, Object> mapping = analysis.analyzedTableElements().toMapping();
assertThat(Joiner.on(", ").withKeyValueSeparator(":").join(mapping), is("_meta:{primary_keys=[id]}, " +
"properties:{" +
"id={index=not_analyzed, store=false, doc_values=true, type=long}, " +
"details={dynamic=true, index=not_analyzed, store=false, properties={" +
"foo={dynamic=true, index=not_analyzed, store=false, properties={" +
"name={index=not_analyzed, store=false, doc_values=true, type=string}, " +
"score={index=not_analyzed, store=false, doc_values=true, type=float}}, doc_values=false, type=object}}, doc_values=false, type=object}}, " +
"_all:{enabled=false}"));
assertThat(mapToSortedString(mapping), is("_all={enabled=false}, " +
"_meta={primary_keys=[id]}, " +
"properties={details={doc_values=false, dynamic=true, index=not_analyzed, properties={" +
"foo={doc_values=false, dynamic=true, index=not_analyzed, properties={" +
"name={doc_values=true, index=not_analyzed, store=false, type=string}, " +
"score={doc_values=true, index=not_analyzed, store=false, type=float}}, store=false, type=object}}, store=false, type=object}, " +
"id={doc_values=true, index=not_analyzed, store=false, type=long}}"));
}

@Test
Expand Down Expand Up @@ -283,13 +282,11 @@ public void testAddNewNestedColumnToNestedObjectColumn() throws Exception {
assertThat(price.dataType(), is("string"));

Map<String, Object> mapping = analysis.analyzedTableElements().toMapping();
assertThat(Joiner.on(", ").withKeyValueSeparator(":").join(mapping), is("_meta:{}, " +
"properties:{" +
"details={dynamic=true, index=not_analyzed, store=false, properties={" +
"stuff={dynamic=true, index=not_analyzed, store=false, properties={" +
"foo={dynamic=true, index=not_analyzed, store=false, properties={" +
"price={index=not_analyzed, store=false, doc_values=true, type=string}, " +
"score={index=not_analyzed, store=false, doc_values=true, type=float}}, doc_values=false, type=object}}, doc_values=false, type=object}}, doc_values=false, type=object}}, " +
"_all:{enabled=false}"));
assertThat(mapToSortedString(mapping), is("_all={enabled=false}, _meta={}, properties={details={doc_values=false, " +
"dynamic=true, index=not_analyzed, properties={stuff={doc_values=false, dynamic=true, index=not_analyzed, " +
"properties={foo={doc_values=false, dynamic=true, index=not_analyzed, " +
"properties={price={doc_values=true, index=not_analyzed, store=false, type=string}, " +
"score={doc_values=true, index=not_analyzed, store=false, type=float}}, store=false, type=object}}, " +
"store=false, type=object}}, store=false, type=object}}"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@

package io.crate.analyze;

import com.google.common.base.Joiner;
import io.crate.metadata.PartitionName;
import io.crate.exceptions.ColumnUnknownException;
import io.crate.metadata.FulltextAnalyzerResolver;
import io.crate.metadata.MetaDataModule;
import io.crate.metadata.PartitionName;
import io.crate.metadata.ReferenceInfos;
import io.crate.metadata.information.MetaDataInformationModule;
import io.crate.metadata.sys.MetaDataSysModule;
Expand All @@ -43,9 +42,8 @@
import java.util.List;
import java.util.Map;

import static org.hamcrest.MatcherAssert.assertThat;
import static io.crate.testing.TestingHelpers.mapToSortedString;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -105,8 +103,8 @@ public void testPartitionedBy() throws Exception {

// partitioned columns must be not indexed in mapping
Map<String, Object> nameMapping = (Map<String, Object>)analysis.mappingProperties().get("name");
assertThat(Joiner.on(", ").withKeyValueSeparator(":").join(nameMapping), is(
"index:no, store:false, doc_values:false, type:string"));
assertThat(mapToSortedString(nameMapping), is(
"doc_values=false, index=no, store=false, type=string"));

Map<String, Object> metaMapping = (Map) analysis.mapping().get("_meta");
assertThat((Map<String, Object>) metaMapping.get("columns"), not(hasKey("name")));
Expand All @@ -125,9 +123,9 @@ public void testPartitionedByMultipleColumns() throws Exception {
") partitioned by (name, date)");
assertThat(analysis.partitionedBy().size(), is(2));
Map<String, Object> properties = analysis.mappingProperties();
assertThat(Joiner.on(", ").withKeyValueSeparator(":").join(properties), is(
"date:{index=no, store=false, doc_values=false, type=date}, " +
"name:{index=no, store=false, doc_values=false, type=string}"));
assertThat(mapToSortedString(properties),
is("date={doc_values=false, index=no, store=false, type=date}, " +
"name={doc_values=false, index=no, store=false, type=string}"));
assertThat((Map<String, Object>) ((Map) analysis.mapping().get("_meta")).get("columns"),
allOf(
not(hasKey("name")),
Expand All @@ -149,9 +147,9 @@ public void testPartitionedByNestedColumns() throws Exception {
") partitioned by (date, o['name'])");
assertThat(analysis.partitionedBy().size(), is(2));
Map<String, Object> oMapping = (Map<String, Object>)analysis.mappingProperties().get("o");
assertThat(Joiner.on(", ").withKeyValueSeparator(":").join(oMapping), is(
"dynamic:true, index:not_analyzed, store:false, properties:{"+
"name={index=no, store=false, doc_values=false, type=string}}, doc_values:false, type:object"));
assertThat(mapToSortedString(oMapping), is(
"doc_values=false, dynamic=true, index=not_analyzed, properties={"+
"name={doc_values=false, index=no, store=false, type=string}}, store=false, type=object"));
assertThat((Map<String, Object>) ((Map) analysis.mapping().get("_meta")).get("columns"), not(hasKey("date")));

Map metaColumns = (Map) ((Map) analysis.mapping().get("_meta")).get("columns");
Expand Down Expand Up @@ -230,8 +228,8 @@ public void testPartitionedByPartOfPrimaryKey() throws Exception {
assertThat(analysis.partitionedBy().get(0), contains("id1", "integer"));

Map<String, Object> oMapping = (Map<String, Object>)analysis.mappingProperties().get("id1");
assertThat(Joiner.on(", ").withKeyValueSeparator(":").join(oMapping), is(
"index:no, store:false, doc_values:false, type:integer"));
assertThat(mapToSortedString(oMapping), is(
"doc_values=false, index=no, store=false, type=integer"));
assertThat((Map<String, Object>) ((Map) analysis.mapping().get("_meta")).get("columns"),
not(hasKey("id1")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@
import java.util.List;
import java.util.Map;

import static org.hamcrest.MatcherAssert.assertThat;
import static io.crate.testing.TestingHelpers.mapToSortedString;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -291,16 +290,13 @@ public void testCreateTableWithObjectsArray() throws Exception {
assertThat(Joiner.on(", ").withKeyValueSeparator(":").join(metaMapping), is("primary_keys:[id]"));

Map<String, Object> mappingProperties = analysis.mappingProperties();
assertThat(Joiner.on(", ").withKeyValueSeparator(":").join(mappingProperties), is(
"details:{" +
"inner={dynamic=true, index=not_analyzed, store=false, properties={" +
"tags={inner={index=not_analyzed, store=false, doc_values=false, type=string}, " +
"type=array}, " +
"age={index=not_analyzed, store=false, doc_values=true, type=integer}, " +
"name={index=not_analyzed, store=false, doc_values=true, type=string}}, " +
"doc_values=false, "+
"type=object}, " +
"type=array}, id:{index=not_analyzed, store=false, doc_values=true, type=integer}"));
assertThat(mapToSortedString(mappingProperties),
is("details={inner={doc_values=false, dynamic=true, index=not_analyzed, " +
"properties={age={doc_values=true, index=not_analyzed, store=false, type=integer}, " +
"name={doc_values=true, index=not_analyzed, store=false, type=string}, " +
"tags={inner={doc_values=false, index=not_analyzed, store=false, type=string}, type=array}}," +
" store=false, type=object}, type=array}, " +
"id={doc_values=true, index=not_analyzed, store=false, type=integer}"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

package io.crate.analyze;

import com.google.common.base.Joiner;
import io.crate.sql.tree.*;
import io.crate.test.integration.CrateUnitTest;
import org.junit.Test;

import java.util.Map;

import static io.crate.testing.TestingHelpers.mapToSortedString;
import static org.hamcrest.CoreMatchers.is;

public class MatchOptionsAnalyzedStatementTest extends CrateUnitTest {
Expand All @@ -40,8 +40,8 @@ public void testMatchOptions() throws Exception {
props.add(new GenericProperty("fuzziness", new ParameterExpression(1)));
Map<String, Object> processed = MatchOptionsAnalysis.process(props, new Object[]{12});
assertThat(
Joiner.on(", ").withKeyValueSeparator(":").join(processed),
is("fuzziness:12, operator:and, analyzer:english"));
mapToSortedString(processed),
is("analyzer=english, fuzziness=12, operator=and"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

package io.crate.analyze;

import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import io.crate.analyze.relations.AnalyzedRelation;
Expand Down Expand Up @@ -1194,11 +1193,11 @@ public void testWhereMatchAllOptions() throws Exception {
")");
Function match = (Function) analysis.relation().querySpec().where().query();
Map<String, Object> options = ((Literal<Map<String, Object>>) match.arguments().get(3)).value();
assertThat(Joiner.on(", ").withKeyValueSeparator(":").join(options),
is("zero_terms_query:all, cutoff_frequency:5, minimum_should_match:4, " +
"rewrite:constant_score_boolean, prefix_length:4, tie_breaker:0.75, " +
"slop:3, analyzer:german, boost:4.6, max_expansions:3, fuzzy_rewrite:top_terms_20, " +
"fuzziness:12, operator:or"));
assertThat(mapToSortedString(options),
is("analyzer=german, boost=4.6, cutoff_frequency=5, " +
"fuzziness=12, fuzzy_rewrite=top_terms_20, max_expansions=3, minimum_should_match=4, " +
"operator=or, prefix_length=4, rewrite=constant_score_boolean, slop=3, tie_breaker=0.75, " +
"zero_terms_query=all"));
}

@Test
Expand Down
7 changes: 2 additions & 5 deletions sql/src/test/java/io/crate/analyze/SetAnalyzerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@
import java.util.Arrays;
import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.*;

public class SetAnalyzerTest extends BaseAnalyzerTest {

Expand Down Expand Up @@ -103,7 +100,7 @@ public void testSetStringValue() throws Exception {
@Test
public void testSetInvalidStringValue() throws Exception {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("'something' is not an allowed value. Allowed values are: primaries, none, full");
expectedException.expectMessage("'something' is not an allowed value. Allowed values are:");
analyze("SET GLOBAL PERSISTENT cluster.graceful_stop.min_availability = 'something'");
}

Expand Down
Loading

0 comments on commit 5659580

Please sign in to comment.