Skip to content

Update from upstream #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
May 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2b68768
Move wasNull to subclass from BaseTypeHandler #1242
kazuki43zoo Apr 9, 2018
a60f3a9
fixes #1260 When scanning super types, replace type variables with ac…
harawata Apr 21, 2018
194da4e
Resolved compiler warnings. Avoid synthetic accessor method being gen…
harawata Apr 21, 2018
36b3917
Add tests parameter mapping and result mapping for member access #1258
kazuki43zoo Apr 22, 2018
e155f8e
Change a logic for controlling accessible member on OGNL #1258
kazuki43zoo Apr 22, 2018
ad286ef
Ensure that all results are processed when executing multiple stateme…
harawata Apr 25, 2018
36ba744
Avoid compile warning using @SuppressWarnings(unused) on test case #1258
kazuki43zoo Apr 24, 2018
7282f76
Merge pull request #1244 from kazuki43zoo/gh-1242_move-wasNull-to-sub…
kazuki43zoo Apr 25, 2018
b1122f8
Polishing See #1209
kazuki43zoo Apr 28, 2018
9829703
A new type handler for SQLXML data type. (#1221)
harawata May 2, 2018
81aafdf
Add unit tests on SqlxmlTypeHandlerTest
kazuki43zoo May 2, 2018
a9325c9
Polishing SqlxmlTypeHandlerTest
kazuki43zoo May 3, 2018
de04ded
Add explanation for SqlxmlTypeHandler on doc
kazuki43zoo May 3, 2018
96a0bf1
Update copyright year
kazuki43zoo May 3, 2018
6fe0f77
Replace to auto-close instead of explicit close on test that using Sq…
kazuki43zoo May 3, 2018
999a442
Merge pull request #1268 from kazuki43zoo/use-auto-close-sqlsession-o…
kazuki43zoo May 3, 2018
afc0f77
Change to calling BaseDataTest#runScript on setup test data
kazuki43zoo May 3, 2018
aab059d
Merge pull request #1269 from kazuki43zoo/setup-test-data
kazuki43zoo May 3, 2018
03c19df
Change to use try-with-resources on test
kazuki43zoo May 3, 2018
d5f024c
Merge pull request #1270 from kazuki43zoo/try-with-resources
kazuki43zoo May 3, 2018
2bc4ce2
Support constructor-auto-mapping using super type #1240
kazuki43zoo Apr 2, 2018
8c98dff
Polishing #1240
kazuki43zoo Apr 2, 2018
b20cf31
Enhance fix for #1240 using @jeffgbutler always choose if single cons…
h3adache May 5, 2018
fd7fc5f
Merge pull request #1277 from mybatis/pr-1240
h3adache May 15, 2018
e67eac9
minor code cleanup.
wuwen5 May 17, 2018
d74d0bd
Merge pull request #1284 from wuwen5/minor-code-clean
kazuki43zoo May 26, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 1 addition & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,13 @@
</distributionManagement>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.testTarget>1.8</maven.compiler.testTarget>
<maven.compiler.testSource>1.8</maven.compiler.testSource>
<maven.compiler.testCompilerArgument>-parameters</maven.compiler.testCompilerArgument>
<clirr.comparisonVersion>3.3.1</clirr.comparisonVersion>
<spotbugs.onlyAnalyze>org.apache.ibatis.*</spotbugs.onlyAnalyze>
<osgi.export>org.apache.ibatis.*;version=${project.version};-noimport:=true</osgi.export>
<osgi.import>*;resolution:=optional</osgi.import>
<osgi.dynamicImport>*</osgi.dynamicImport>
<maven.surefire.excludeGroups>org.apache.ibatis.test.SlowTests</maven.surefire.excludeGroups>

<!-- Override: Animal Sniffer Signature -->
<signature.artifact>java18</signature.artifact>
<signature.version>1.0</signature.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -204,7 +196,7 @@
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.1.0</version>
<version>${junit-engine.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/org/apache/ibatis/binding/MapperProxy.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2009-2017 the original author or authors.
* Copyright 2009-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -60,12 +60,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
}

private MapperMethod cachedMapperMethod(Method method) {
MapperMethod mapperMethod = methodCache.get(method);
if (mapperMethod == null) {
mapperMethod = new MapperMethod(mapperInterface, method, sqlSession.getConfiguration());
methodCache.put(method, mapperMethod);
}
return mapperMethod;
return methodCache.computeIfAbsent(method, k -> new MapperMethod(mapperInterface, method, sqlSession.getConfiguration()));
}

@UsesJava7
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2009-2015 the original author or authors.
* Copyright 2009-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,7 @@
public class MapperProxyFactory<T> {

private final Class<T> mapperInterface;
private final Map<Method, MapperMethod> methodCache = new ConcurrentHashMap<Method, MapperMethod>();
private final Map<Method, MapperMethod> methodCache = new ConcurrentHashMap<>();

public MapperProxyFactory(Class<T> mapperInterface) {
this.mapperInterface = mapperInterface;
Expand All @@ -48,7 +48,7 @@ protected T newInstance(MapperProxy<T> mapperProxy) {
}

public T newInstance(SqlSession sqlSession) {
final MapperProxy<T> mapperProxy = new MapperProxy<T>(sqlSession, mapperInterface, methodCache);
final MapperProxy<T> mapperProxy = new MapperProxy<>(sqlSession, mapperInterface, methodCache);
return newInstance(mapperProxy);
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/apache/ibatis/binding/MapperRegistry.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2009-2015 the original author or authors.
* Copyright 2009-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,7 +34,7 @@
public class MapperRegistry {

private final Configuration config;
private final Map<Class<?>, MapperProxyFactory<?>> knownMappers = new HashMap<Class<?>, MapperProxyFactory<?>>();
private final Map<Class<?>, MapperProxyFactory<?>> knownMappers = new HashMap<>();

public MapperRegistry(Configuration config) {
this.config = config;
Expand Down Expand Up @@ -90,7 +90,7 @@ public Collection<Class<?>> getMappers() {
* @since 3.2.2
*/
public void addMappers(String packageName, Class<?> superType) {
ResolverUtil<Class<?>> resolverUtil = new ResolverUtil<Class<?>>();
ResolverUtil<Class<?>> resolverUtil = new ResolverUtil<>();
resolverUtil.find(new ResolverUtil.IsA(superType), packageName);
Set<Class<? extends Class<?>>> mapperSet = resolverUtil.getClasses();
for (Class<?> mapperClass : mapperSet) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/ibatis/builder/BaseBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected Integer integerValueOf(String value, Integer defaultValue) {

protected Set<String> stringSetValueOf(String value, String defaultValue) {
value = (value == null ? defaultValue : value);
return new HashSet<String>(Arrays.asList(value.split(",")));
return new HashSet<>(Arrays.asList(value.split(",")));
}

protected JdbcType resolveJdbcType(String alias) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public ResultMap addResultMap(
throw new IncompleteElementException("Could not find a parent resultmap with id '" + extend + "'");
}
ResultMap resultMap = configuration.getResultMap(extend);
List<ResultMapping> extendedResultMappings = new ArrayList<ResultMapping>(resultMap.getResultMappings());
List<ResultMapping> extendedResultMappings = new ArrayList<>(resultMap.getResultMappings());
extendedResultMappings.removeAll(resultMappings);
// Remove parent constructor if this resultMap declares a constructor.
boolean declaresConstructor = false;
Expand Down Expand Up @@ -237,7 +237,7 @@ public Discriminator buildDiscriminator(
null,
null,
false);
Map<String, String> namespaceDiscriminatorMap = new HashMap<String, String>();
Map<String, String> namespaceDiscriminatorMap = new HashMap<>();
for (Map.Entry<String, String> e : discriminatorMap.entrySet()) {
String resultMap = e.getValue();
resultMap = applyCurrentNamespace(resultMap, true);
Expand Down Expand Up @@ -320,7 +320,7 @@ private ParameterMap getStatementParameterMap(
throw new IncompleteElementException("Could not find parameter map " + parameterMapName, e);
}
} else if (parameterTypeClass != null) {
List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>();
List<ParameterMapping> parameterMappings = new ArrayList<>();
parameterMap = new ParameterMap.Builder(
configuration,
statementId + "-Inline",
Expand All @@ -336,7 +336,7 @@ private List<ResultMap> getStatementResultMaps(
String statementId) {
resultMap = applyCurrentNamespace(resultMap, true);

List<ResultMap> resultMaps = new ArrayList<ResultMap>();
List<ResultMap> resultMaps = new ArrayList<>();
if (resultMap != null) {
String[] resultMapNames = resultMap.split(",");
for (String resultMapName : resultMapNames) {
Expand Down Expand Up @@ -392,7 +392,7 @@ public ResultMapping buildResultMapping(
}

private Set<String> parseMultipleColumnNames(String columnName) {
Set<String> columns = new HashSet<String>();
Set<String> columns = new HashSet<>();
if (columnName != null) {
if (columnName.indexOf(',') > -1) {
StringTokenizer parser = new StringTokenizer(columnName, "{}, ", false);
Expand All @@ -408,7 +408,7 @@ private Set<String> parseMultipleColumnNames(String columnName) {
}

private List<ResultMapping> parseCompositeColumnName(String columnName) {
List<ResultMapping> composites = new ArrayList<ResultMapping>();
List<ResultMapping> composites = new ArrayList<>();
if (columnName != null && (columnName.indexOf('=') > -1 || columnName.indexOf(',') > -1)) {
StringTokenizer parser = new StringTokenizer(columnName, "{}=, ", false);
while (parser.hasMoreTokens()) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/apache/ibatis/builder/SqlSourceBuilder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2009-2017 the original author or authors.
* Copyright 2009-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -48,7 +48,7 @@ public SqlSource parse(String originalSql, Class<?> parameterType, Map<String, O

private static class ParameterMappingTokenHandler extends BaseBuilder implements TokenHandler {

private List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>();
private List<ParameterMapping> parameterMappings = new ArrayList<>();
private Class<?> parameterType;
private MetaObject metaParameters;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private String generateResultMapName(Method method) {
}

private void applyResultMap(String resultMapId, Class<?> returnType, Arg[] args, Result[] results, TypeDiscriminator discriminator) {
List<ResultMapping> resultMappings = new ArrayList<ResultMapping>();
List<ResultMapping> resultMappings = new ArrayList<>();
applyConstructorArgs(args, returnType, resultMappings);
applyResults(results, returnType, resultMappings);
Discriminator disc = applyDiscriminator(resultMapId, returnType, discriminator);
Expand All @@ -258,7 +258,7 @@ private void createDiscriminatorResultMaps(String resultMapId, Class<?> resultTy
if (discriminator != null) {
for (Case c : discriminator.cases()) {
String caseResultMapId = resultMapId + "-" + c.value();
List<ResultMapping> resultMappings = new ArrayList<ResultMapping>();
List<ResultMapping> resultMappings = new ArrayList<>();
// issue #136
applyConstructorArgs(c.constructArgs(), resultType, resultMappings);
applyResults(c.results(), resultType, resultMappings);
Expand All @@ -277,7 +277,7 @@ private Discriminator applyDiscriminator(String resultMapId, Class<?> resultType
Class<? extends TypeHandler<?>> typeHandler = (Class<? extends TypeHandler<?>>)
(discriminator.typeHandler() == UnknownTypeHandler.class ? null : discriminator.typeHandler());
Case[] cases = discriminator.cases();
Map<String, String> discriminatorMap = new HashMap<String, String>();
Map<String, String> discriminatorMap = new HashMap<>();
for (Case c : cases) {
String value = c.value();
String caseResultMapId = resultMapId + "-" + value;
Expand Down Expand Up @@ -537,7 +537,7 @@ private Class<? extends Annotation> chooseAnnotationType(Method method, Set<Clas

private void applyResults(Result[] results, Class<?> resultType, List<ResultMapping> resultMappings) {
for (Result result : results) {
List<ResultFlag> flags = new ArrayList<ResultFlag>();
List<ResultFlag> flags = new ArrayList<>();
if (result.id()) {
flags.add(ResultFlag.ID);
}
Expand Down Expand Up @@ -593,7 +593,7 @@ private boolean hasNestedSelect(Result result) {

private void applyConstructorArgs(Arg[] args, Class<?> resultType, List<ResultMapping> resultMappings) {
for (Arg arg : args) {
List<ResultFlag> flags = new ArrayList<ResultFlag>();
List<ResultFlag> flags = new ArrayList<>();
flags.add(ResultFlag.CONSTRUCTOR);
if (arg.id()) {
flags.add(ResultFlag.ID);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2009-2017 the original author or authors.
* Copyright 2009-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -120,7 +120,7 @@ private Properties getVariablesContext(Node node, Properties inheritedVariablesC
// Replace variables inside
String value = PropertyParser.parse(getStringAttribute(n, "value"), inheritedVariablesContext);
if (declaredProperties == null) {
declaredProperties = new HashMap<String, String>();
declaredProperties = new HashMap<>();
}
if (declaredProperties.put(name, value) != null) {
throw new BuilderException("Variable " + name + " defined twice in the same include definition");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private void parameterMapElement(List<XNode> list) throws Exception {
String type = parameterMapNode.getStringAttribute("type");
Class<?> parameterClass = resolveClass(type);
List<XNode> parameterNodes = parameterMapNode.evalNodes("parameter");
List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>();
List<ParameterMapping> parameterMappings = new ArrayList<>();
for (XNode parameterNode : parameterNodes) {
String property = parameterNode.getStringAttribute("property");
String javaType = parameterNode.getStringAttribute("javaType");
Expand Down Expand Up @@ -264,7 +264,7 @@ private ResultMap resultMapElement(XNode resultMapNode, List<ResultMapping> addi
Boolean autoMapping = resultMapNode.getBooleanAttribute("autoMapping");
Class<?> typeClass = resolveClass(type);
Discriminator discriminator = null;
List<ResultMapping> resultMappings = new ArrayList<ResultMapping>();
List<ResultMapping> resultMappings = new ArrayList<>();
resultMappings.addAll(additionalResultMappings);
List<XNode> resultChildren = resultMapNode.getChildren();
for (XNode resultChild : resultChildren) {
Expand All @@ -273,7 +273,7 @@ private ResultMap resultMapElement(XNode resultMapNode, List<ResultMapping> addi
} else if ("discriminator".equals(resultChild.getName())) {
discriminator = processDiscriminatorElement(resultChild, typeClass, resultMappings);
} else {
List<ResultFlag> flags = new ArrayList<ResultFlag>();
List<ResultFlag> flags = new ArrayList<>();
if ("id".equals(resultChild.getName())) {
flags.add(ResultFlag.ID);
}
Expand All @@ -292,7 +292,7 @@ private ResultMap resultMapElement(XNode resultMapNode, List<ResultMapping> addi
private void processConstructorElement(XNode resultChild, Class<?> resultType, List<ResultMapping> resultMappings) throws Exception {
List<XNode> argChildren = resultChild.getChildren();
for (XNode argChild : argChildren) {
List<ResultFlag> flags = new ArrayList<ResultFlag>();
List<ResultFlag> flags = new ArrayList<>();
flags.add(ResultFlag.CONSTRUCTOR);
if ("idArg".equals(argChild.getName())) {
flags.add(ResultFlag.ID);
Expand All @@ -310,7 +310,7 @@ private Discriminator processDiscriminatorElement(XNode context, Class<?> result
@SuppressWarnings("unchecked")
Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(typeHandler);
JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
Map<String, String> discriminatorMap = new HashMap<String, String>();
Map<String, String> discriminatorMap = new HashMap<>();
for (XNode caseChild : context.getChildren()) {
String value = caseChild.getStringAttribute("value");
String resultMap = caseChild.getStringAttribute("resultMap", processNestedResultMappings(caseChild, resultMappings));
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/apache/ibatis/cache/CacheKey.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2009-2017 the original author or authors.
* Copyright 2009-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,7 +44,7 @@ public CacheKey() {
this.hashcode = DEFAULT_HASHCODE;
this.multiplier = DEFAULT_MULTIPLYER;
this.count = 0;
this.updateList = new ArrayList<Object>();
this.updateList = new ArrayList<>();
}

public CacheKey(Object[] objects) {
Expand Down Expand Up @@ -122,7 +122,7 @@ public String toString() {
@Override
public CacheKey clone() throws CloneNotSupportedException {
CacheKey clonedCacheKey = (CacheKey) super.clone();
clonedCacheKey.updateList = new ArrayList<Object>(updateList);
clonedCacheKey.updateList = new ArrayList<>(updateList);
return clonedCacheKey;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2009-2017 the original author or authors.
* Copyright 2009-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,7 +25,7 @@
*/
public class TransactionalCacheManager {

private final Map<Cache, TransactionalCache> transactionalCaches = new HashMap<Cache, TransactionalCache>();
private final Map<Cache, TransactionalCache> transactionalCaches = new HashMap<>();

public void clear(Cache cache) {
getTransactionalCache(cache).clear();
Expand All @@ -52,12 +52,7 @@ public void rollback() {
}

private TransactionalCache getTransactionalCache(Cache cache) {
TransactionalCache txCache = transactionalCaches.get(cache);
if (txCache == null) {
txCache = new TransactionalCache(cache);
transactionalCaches.put(cache, txCache);
}
return txCache;
return transactionalCaches.computeIfAbsent(cache, TransactionalCache::new);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2009-2015 the original author or authors.
* Copyright 2009-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,7 +42,7 @@ public class BlockingCache implements Cache {

public BlockingCache(Cache delegate) {
this.delegate = delegate;
this.locks = new ConcurrentHashMap<Object, ReentrantLock>();
this.locks = new ConcurrentHashMap<>();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2009-2017 the original author or authors.
* Copyright 2009-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,7 +34,7 @@ public class FifoCache implements Cache {

public FifoCache(Cache delegate) {
this.delegate = delegate;
this.keyList = new LinkedList<Object>();
this.keyList = new LinkedList<>();
this.size = 1024;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2009-2015 the original author or authors.
* Copyright 2009-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,8 +38,8 @@ public class SoftCache implements Cache {
public SoftCache(Cache delegate) {
this.delegate = delegate;
this.numberOfHardLinks = 256;
this.hardLinksToAvoidGarbageCollection = new LinkedList<Object>();
this.queueOfGarbageCollectedEntries = new ReferenceQueue<Object>();
this.hardLinksToAvoidGarbageCollection = new LinkedList<>();
this.queueOfGarbageCollectedEntries = new ReferenceQueue<>();
}

@Override
Expand Down
Loading