Fixed CGLIB proxy class leaks through further equals/hashCode implementations in Spring AOP pointcuts

Issue: SPR-8008
This commit is contained in:
Juergen Hoeller
2012-12-11 20:36:59 +01:00
committed by unknown
parent 7af92b483a
commit 801d4714b1
7 changed files with 147 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2012 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.
@@ -97,6 +97,18 @@ public class AnnotationTransactionAttributeSource extends AbstractFallbackTransa
this.annotationParsers = Collections.singleton(annotationParser);
}
/**
* Create a custom AnnotationTransactionAttributeSource.
* @param annotationParsers the TransactionAnnotationParsers to use
*/
public AnnotationTransactionAttributeSource(TransactionAnnotationParser... annotationParsers) {
this.publicMethodsOnly = true;
Assert.notEmpty(annotationParsers, "At least one TransactionAnnotationParser needs to be specified");
Set<TransactionAnnotationParser> parsers = new LinkedHashSet<TransactionAnnotationParser>(annotationParsers.length);
Collections.addAll(parsers, annotationParsers);
this.annotationParsers = parsers;
}
/**
* Create a custom AnnotationTransactionAttributeSource.
* @param annotationParsers the TransactionAnnotationParsers to use
@@ -147,4 +159,23 @@ public class AnnotationTransactionAttributeSource extends AbstractFallbackTransa
return this.publicMethodsOnly;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AnnotationTransactionAttributeSource)) {
return false;
}
AnnotationTransactionAttributeSource otherTas = (AnnotationTransactionAttributeSource) other;
return (this.annotationParsers.equals(otherTas.annotationParsers) &&
this.publicMethodsOnly == otherTas.publicMethodsOnly);
}
@Override
public int hashCode() {
return this.annotationParsers.hashCode();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2012 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.
@@ -47,6 +47,16 @@ public class Ejb3TransactionAnnotationParser implements TransactionAnnotationPar
return new Ejb3TransactionAttribute(ann.value());
}
@Override
public boolean equals(Object other) {
return (this == other || other instanceof Ejb3TransactionAnnotationParser);
}
@Override
public int hashCode() {
return Ejb3TransactionAnnotationParser.class.hashCode();
}
/**
* EJB3-specific TransactionAttribute, implementing EJB3's rollback rules
@@ -58,6 +68,7 @@ public class Ejb3TransactionAnnotationParser implements TransactionAnnotationPar
setPropagationBehaviorName(PREFIX_PROPAGATION + type.name());
}
@Override
public boolean rollbackOn(Throwable ex) {
ApplicationException ann = ex.getClass().getAnnotation(ApplicationException.class);
return (ann != null ? ann.rollback() : super.rollbackOn(ex));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 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.
@@ -76,4 +76,14 @@ public class SpringTransactionAnnotationParser implements TransactionAnnotationP
return rbta;
}
@Override
public boolean equals(Object other) {
return (this == other || other instanceof SpringTransactionAnnotationParser);
}
@Override
public int hashCode() {
return SpringTransactionAnnotationParser.class.hashCode();
}
}