CPD Results

The following document contains the results of PMD’s CPD 6.21.0.

Duplications

FileLine
org/apache/ibatis/executor/loader/cglib/CglibProxyFactory.java93
org/apache/ibatis/executor/loader/javassist/JavassistProxyFactory.java95
  1. private static class EnhancedResultObjectProxyImpl implements MethodInterceptor {
  2. private final Class<?> type;
  3. private final ResultLoaderMap lazyLoader;
  4. private final boolean aggressive;
  5. private final Set<String> lazyLoadTriggerMethods;
  6. private final ObjectFactory objectFactory;
  7. private final List<Class<?>> constructorArgTypes;
  8. private final List<Object> constructorArgs;
  9. private EnhancedResultObjectProxyImpl(Class<?> type, ResultLoaderMap lazyLoader, Configuration configuration, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
  10. this.type = type;
  11. this.lazyLoader = lazyLoader;
  12. this.aggressive = configuration.isAggressiveLazyLoading();
  13. this.lazyLoadTriggerMethods = configuration.getLazyLoadTriggerMethods();
  14. this.objectFactory = objectFactory;
  15. this.constructorArgTypes = constructorArgTypes;
  16. this.constructorArgs = constructorArgs;
  17. }
  18. public static Object createProxy(Object target, ResultLoaderMap lazyLoader, Configuration configuration, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
  19. final Class<?> type = target.getClass();
  20. EnhancedResultObjectProxyImpl callback = new EnhancedResultObjectProxyImpl(type, lazyLoader, configuration, objectFactory, constructorArgTypes, constructorArgs);
  21. Object enhanced = crateProxy(type, callback, constructorArgTypes, constructorArgs);
  22. PropertyCopier.copyBeanProperties(type, target, enhanced);
  23. return enhanced;
  24. }
  25. @Override
  26. public Object intercept(Object enhanced, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
FileLine
org/apache/ibatis/jdbc/SelectBuilder.java49
org/apache/ibatis/jdbc/SqlBuilder.java76
  1. sql().SELECT_DISTINCT(columns);
  2. }
  3. public static void FROM(String table) {
  4. sql().FROM(table);
  5. }
  6. public static void JOIN(String join) {
  7. sql().JOIN(join);
  8. }
  9. public static void INNER_JOIN(String join) {
  10. sql().INNER_JOIN(join);
  11. }
  12. public static void LEFT_OUTER_JOIN(String join) {
  13. sql().LEFT_OUTER_JOIN(join);
  14. }
  15. public static void RIGHT_OUTER_JOIN(String join) {
  16. sql().RIGHT_OUTER_JOIN(join);
  17. }
  18. public static void OUTER_JOIN(String join) {
  19. sql().OUTER_JOIN(join);
  20. }
  21. public static void WHERE(String conditions) {
  22. sql().WHERE(conditions);
  23. }
  24. public static void OR() {
  25. sql().OR();
  26. }
  27. public static void AND() {
  28. sql().AND();
  29. }
  30. public static void GROUP_BY(String columns) {
  31. sql().GROUP_BY(columns);
  32. }
  33. public static void HAVING(String conditions) {
  34. sql().HAVING(conditions);
  35. }
  36. public static void ORDER_BY(String columns) {
  37. sql().ORDER_BY(columns);
  38. }
FileLine
org/apache/ibatis/type/ClobTypeHandler.java28
org/apache/ibatis/type/NClobTypeHandler.java28
  1. public class ClobTypeHandler extends BaseTypeHandler<String> {
  2. @Override
  3. public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType)
  4. throws SQLException {
  5. StringReader reader = new StringReader(parameter);
  6. ps.setCharacterStream(i, reader, parameter.length());
  7. }
  8. @Override
  9. public String getNullableResult(ResultSet rs, String columnName)
  10. throws SQLException {
  11. Clob clob = rs.getClob(columnName);
  12. return toString(clob);
  13. }
  14. @Override
  15. public String getNullableResult(ResultSet rs, int columnIndex)
  16. throws SQLException {
  17. Clob clob = rs.getClob(columnIndex);
  18. return toString(clob);
  19. }
  20. @Override
  21. public String getNullableResult(CallableStatement cs, int columnIndex)
  22. throws SQLException {
  23. Clob clob = cs.getClob(columnIndex);
  24. return toString(clob);
  25. }
  26. private String toString(Clob clob) throws SQLException {
  27. return clob == null ? null : clob.getSubString(1, (int) clob.length());
  28. }
  29. }
FileLine
org/apache/ibatis/executor/loader/cglib/CglibProxyFactory.java162
org/apache/ibatis/executor/loader/javassist/JavassistProxyFactory.java164
  1. private static class EnhancedDeserializationProxyImpl extends AbstractEnhancedDeserializationProxy implements MethodInterceptor {
  2. private EnhancedDeserializationProxyImpl(Class<?> type, Map<String, ResultLoaderMap.LoadPair> unloadedProperties, ObjectFactory objectFactory,
  3. List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
  4. super(type, unloadedProperties, objectFactory, constructorArgTypes, constructorArgs);
  5. }
  6. public static Object createProxy(Object target, Map<String, ResultLoaderMap.LoadPair> unloadedProperties, ObjectFactory objectFactory,
  7. List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
  8. final Class<?> type = target.getClass();
  9. EnhancedDeserializationProxyImpl callback = new EnhancedDeserializationProxyImpl(type, unloadedProperties, objectFactory, constructorArgTypes, constructorArgs);
  10. Object enhanced = crateProxy(type, callback, constructorArgTypes, constructorArgs);
  11. PropertyCopier.copyBeanProperties(type, target, enhanced);
  12. return enhanced;
  13. }
  14. @Override
  15. public Object intercept(Object enhanced, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
FileLine
org/apache/ibatis/executor/loader/cglib/CglibProxyFactory.java135
org/apache/ibatis/executor/loader/javassist/JavassistProxyFactory.java137
  1. return new CglibSerialStateHolder(original, lazyLoader.getProperties(), objectFactory, constructorArgTypes, constructorArgs);
  2. } else {
  3. return original;
  4. }
  5. } else {
  6. if (lazyLoader.size() > 0 && !FINALIZE_METHOD.equals(methodName)) {
  7. if (aggressive || lazyLoadTriggerMethods.contains(methodName)) {
  8. lazyLoader.loadAll();
  9. } else if (PropertyNamer.isSetter(methodName)) {
  10. final String property = PropertyNamer.methodToProperty(methodName);
  11. lazyLoader.remove(property);
  12. } else if (PropertyNamer.isGetter(methodName)) {
  13. final String property = PropertyNamer.methodToProperty(methodName);
  14. if (lazyLoader.hasLoader(property)) {
  15. lazyLoader.load(property);
  16. }
  17. }
  18. }
  19. }
  20. }
  21. return methodProxy.invokeSuper(enhanced, args);
FileLine
org/apache/ibatis/logging/commons/JakartaCommonsLoggingImpl.java29
org/apache/ibatis/logging/slf4j/Slf4jImpl.java47
  1. log = LogFactory.getLog(clazz);
  2. }
  3. @Override
  4. public boolean isDebugEnabled() {
  5. return log.isDebugEnabled();
  6. }
  7. @Override
  8. public boolean isTraceEnabled() {
  9. return log.isTraceEnabled();
  10. }
  11. @Override
  12. public void error(String s, Throwable e) {
  13. log.error(s, e);
  14. }
  15. @Override
  16. public void error(String s) {
  17. log.error(s);
  18. }
  19. @Override
  20. public void debug(String s) {
  21. log.debug(s);
  22. }
  23. @Override
  24. public void trace(String s) {
  25. log.trace(s);
  26. }
  27. @Override
  28. public void warn(String s) {
  29. log.warn(s);
  30. }
  31. }
FileLine
org/apache/ibatis/logging/commons/JakartaCommonsLoggingImpl.java30
org/apache/ibatis/logging/log4j2/Log4j2Impl.java38
org/apache/ibatis/logging/slf4j/Slf4jImpl.java48
org/apache/ibatis/logging/slf4j/Slf4jLoggerImpl.java30
  1. }
  2. @Override
  3. public boolean isDebugEnabled() {
  4. return log.isDebugEnabled();
  5. }
  6. @Override
  7. public boolean isTraceEnabled() {
  8. return log.isTraceEnabled();
  9. }
  10. @Override
  11. public void error(String s, Throwable e) {
  12. log.error(s, e);
  13. }
  14. @Override
  15. public void error(String s) {
  16. log.error(s);
  17. }
  18. @Override
  19. public void debug(String s) {
  20. log.debug(s);
  21. }
  22. @Override
  23. public void trace(String s) {
  24. log.trace(s);
  25. }
  26. @Override
  27. public void warn(String s) {
  28. log.warn(s);
  29. }
  30. }
FileLine
org/apache/ibatis/executor/loader/cglib/CglibProxyFactory.java54
org/apache/ibatis/executor/loader/javassist/JavassistProxyFactory.java53
  1. throw new IllegalStateException(“Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath.”, e);
  2. }
  3. }
  4. @Override
  5. public Object createProxy(Object target, ResultLoaderMap lazyLoader, Configuration configuration, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
  6. return EnhancedResultObjectProxyImpl.createProxy(target, lazyLoader, configuration, objectFactory, constructorArgTypes, constructorArgs);
  7. }
  8. public Object createDeserializationProxy(Object target, Map<String, ResultLoaderMap.LoadPair> unloadedProperties, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
  9. return EnhancedDeserializationProxyImpl.createProxy(target, unloadedProperties, objectFactory, constructorArgTypes, constructorArgs);
  10. }
  11. static Object crateProxy(Class<?> type, Callback callback, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
FileLine
org/apache/ibatis/cache/decorators/SoftCache.java71
org/apache/ibatis/cache/decorators/WeakCache.java71
  1. result = softReference.get();
  2. if (result == null) {
  3. delegate.removeObject(key);
  4. } else {
  5. // See #586 (and #335) modifications need more than a read lock
  6. synchronized (hardLinksToAvoidGarbageCollection) {
  7. hardLinksToAvoidGarbageCollection.addFirst(result);
  8. if (hardLinksToAvoidGarbageCollection.size() > numberOfHardLinks) {
  9. hardLinksToAvoidGarbageCollection.removeLast();
  10. }
  11. }
  12. }
  13. }
  14. return result;
  15. }
  16. @Override
  17. public Object removeObject(Object key) {
  18. removeGarbageCollectedItems();
  19. return delegate.removeObject(key);
  20. }
  21. @Override
  22. public void clear() {
  23. synchronized (hardLinksToAvoidGarbageCollection) {
  24. hardLinksToAvoidGarbageCollection.clear();
  25. }
  26. removeGarbageCollectedItems();
  27. delegate.clear();
  28. }
  29. private void removeGarbageCollectedItems() {
FileLine
org/apache/ibatis/cache/decorators/SoftCache.java37
org/apache/ibatis/cache/decorators/WeakCache.java37
  1. public SoftCache(Cache delegate) {
  2. this.delegate = delegate;
  3. this.numberOfHardLinks = 256;
  4. this.hardLinksToAvoidGarbageCollection = new LinkedList<>();
  5. this.queueOfGarbageCollectedEntries = new ReferenceQueue<>();
  6. }
  7. @Override
  8. public String getId() {
  9. return delegate.getId();
  10. }
  11. @Override
  12. public int getSize() {
  13. removeGarbageCollectedItems();
  14. return delegate.getSize();
  15. }
  16. public void setSize(int size) {
  17. this.numberOfHardLinks = size;
  18. }
  19. @Override
  20. public void putObject(Object key, Object value) {
  21. removeGarbageCollectedItems();
  22. delegate.putObject(key, new SoftEntry(key, value, queueOfGarbageCollectedEntries));