Skip to content
Permalink
Browse files

WFLY-11854 Distributable session manager cannot detect immutable exte…

…rnal classes
  • Loading branch information
pferraro committed Apr 16, 2019
1 parent 87ce247 commit 58da59ed8d9700004a8c09e26250d98d537d021b
Showing with 943 additions and 280 deletions.
  1. +107 −0 clustering/ee/spi/src/main/java/org/wildfly/clustering/ee/CompositeIterable.java
  2. +69 −0 clustering/ee/spi/src/main/java/org/wildfly/clustering/ee/CompositeIterator.java
  3. +31 −172 clustering/ee/spi/src/main/java/org/wildfly/clustering/ee/Immutability.java
  4. +45 −0 clustering/ee/spi/src/main/java/org/wildfly/clustering/ee/immutable/AnnotationImmutability.java
  5. +9 −9 clustering/ee/spi/src/main/java/org/wildfly/clustering/ee/{ → immutable}/CollectionImmutability.java
  6. +56 −0 clustering/ee/spi/src/main/java/org/wildfly/clustering/ee/immutable/CompositeImmutability.java
  7. +155 −0 clustering/ee/spi/src/main/java/org/wildfly/clustering/ee/immutable/DefaultImmutability.java
  8. +51 −0 clustering/ee/spi/src/main/java/org/wildfly/clustering/ee/immutable/IdentityImmutability.java
  9. +46 −0 clustering/ee/spi/src/main/java/org/wildfly/clustering/ee/immutable/InstanceOfImmutability.java
  10. +73 −0 clustering/ee/spi/src/main/java/org/wildfly/clustering/ee/immutable/SimpleImmutability.java
  11. +61 −0 clustering/ee/spi/src/test/java/org/wildfly/clustering/ee/CompositeIterableTestCase.java
  12. +6 −5 clustering/ee/spi/src/test/java/org/wildfly/clustering/ee/{ → immutable}/ImmutabilityTestCase.java
  13. +8 −0 ...java/org/wildfly/extension/clustering/web/deployment/DistributableWebDeploymentConfiguration.java
  14. +7 −0 ...rg/wildfly/extension/clustering/web/deployment/DistributableWebDeploymentDependencyProcessor.java
  15. +53 −7 ...ain/java/org/wildfly/extension/clustering/web/deployment/DistributableWebDeploymentXMLReader.java
  16. +16 −1 .../org/wildfly/extension/clustering/web/deployment/MutableDistributableDeploymentConfiguration.java
  17. +47 −26 clustering/web/extension/src/main/resources/schema/distributable-web_1_0.xsd
  18. +9 −0 .../org/wildfly/extension/clustering/web/deployment/DistributableWebDeploymentXMLReaderTestCase.java
  19. +4 −1 ...sion/src/test/resources/org/wildfly/extension/clustering/web/deployment/distributable-web-1.0.xml
  20. +2 −0 ...st/resources/org/wildfly/extension/clustering/web/deployment/distributable-web-infinispan-1.0.xml
  21. +4 −2 .../src/main/java/org/wildfly/clustering/web/infinispan/session/InfinispanSessionManagerFactory.java
  22. +6 −0 ...wildfly/clustering/web/infinispan/session/InfinispanSessionManagerFactoryServiceConfigurator.java
  23. +5 −3 ...n/src/main/java/org/wildfly/clustering/web/infinispan/session/coarse/CoarseSessionAttributes.java
  24. +5 −2 ...ain/java/org/wildfly/clustering/web/infinispan/session/coarse/CoarseSessionAttributesFactory.java
  25. +6 −4 ...ispan/src/main/java/org/wildfly/clustering/web/infinispan/session/fine/FineSessionAttributes.java
  26. +5 −2 ...rc/main/java/org/wildfly/clustering/web/infinispan/session/fine/FineSessionAttributesFactory.java
  27. +2 −0 .../spi/src/main/java/org/wildfly/clustering/web/session/DistributableSessionManagementProvider.java
  28. +13 −34 ...tering/web/spi/src/main/java/org/wildfly/clustering/web/session/SessionAttributeImmutability.java
  29. +3 −0 .../web/spi/src/main/java/org/wildfly/clustering/web/session/SessionManagerFactoryConfiguration.java
  30. +6 −6 ...eb/spi/src/test/java/org/wildfly/clustering/web/session/SessionAttributeImmutabilityTestCase.java
  31. +3 −2 ...ildfly/clustering/web/undertow/session/DistributableSessionManagerFactoryServiceConfigurator.java
  32. +18 −1 ...n/java/org/wildfly/clustering/web/undertow/session/SessionManagerFactoryConfigurationAdapter.java
  33. +5 −2 ...a/org/wildfly/clustering/web/undertow/session/UndertowDistributableSessionManagementProvider.java
  34. +7 −1 ...in/java/org/wildfly/clustering/web/undertow/session/UndertowSessionManagementProviderFactory.java
@@ -0,0 +1,107 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.wildfly.clustering.ee;

import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;

/**
* Used for iterating over an series of iterables, thus avoiding the need to allocate/populate a new list containing all elements.
* More efficient than the alternative when the number of iterables is arbitrary and small relative to the size of each iterable.
* @author Paul Ferraro
*/
public class CompositeIterable<T> implements Iterable<T> {

private final List<? extends Iterable<? extends T>> iterables;

/**
* Constructs a new composite iterable.
* @param iterables a series of iterables
*/
@SafeVarargs
public CompositeIterable(Iterable<? extends T>... iterables) {
this(Arrays.asList(iterables));
}

/**
* Constructs a new composite iterable.
* @param iterables a series of iterables
*/
public CompositeIterable(List<? extends Iterable<? extends T>> iterables) {
this.iterables = iterables;
}

@Override
public Iterator<T> iterator() {
List<Iterator<? extends T>> iterators = new ArrayList<>(this.iterables.size());
for (Iterable<? extends T> elements : this.iterables) {
iterators.add(elements.iterator());
}
return new CompositeIterator<>(iterators);
}

@Override
public int hashCode() {
int result = 1;
for (Iterable<? extends T> elements : this.iterables) {
for (T element : elements) {
result = 31 * result + ((element != null) ? element.hashCode() : 0);
}
}
return result;
}

@Override
public boolean equals(Object object) {
if (!(object instanceof Iterable)) return false;
@SuppressWarnings("unchecked")
Iterator<Object> otherElements = ((Iterable<Object>) object).iterator();
for (Iterable<? extends T> iterable : this.iterables) {
Iterator<? extends T> elements = iterable.iterator();
while (elements.hasNext() && otherElements.hasNext()) {
elements.next().equals(otherElements.next());
}
if (elements.hasNext()) return false;
}
return !otherElements.hasNext();
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append('[');
Iterator<? extends Iterable<? extends T>> iterables = this.iterables.iterator();
while (iterables.hasNext()) {
Iterator<? extends T> elements = iterables.next().iterator();
while (elements.hasNext()) {
if (builder.length() > 1) {
builder.append(',').append(' ');
}
builder.append(elements.next());
}
}
return builder.append(']').toString();
}
}
@@ -0,0 +1,69 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.wildfly.clustering.ee;

import java.util.Arrays;
import java.util.Iterator;
import java.util.NoSuchElementException;

/**
* Iterator that iterates over a series of iterators.
* @author Paul Ferraro
*/
public class CompositeIterator<E> implements Iterator<E> {

private final Iterable<? extends Iterator<? extends E>> iterators;

/**
* Constructs a new composite iterator.
* @param iterables a series of iterators
*/
@SafeVarargs
public CompositeIterator(Iterator<? extends E>... iterators) {
this(Arrays.asList(iterators));
}

/**
* Constructs a new composite iterator.
* @param iterables a series of iterators
*/
public CompositeIterator(Iterable<? extends Iterator<? extends E>> iterators) {
this.iterators = iterators;
}

@Override
public boolean hasNext() {
for (Iterator<? extends E> iterator : this.iterators) {
if (iterator.hasNext()) return true;
}
return false;
}

@Override
public E next() {
for (Iterator<? extends E> iterator : this.iterators) {
if (iterator.hasNext()) return iterator.next();
}
throw new NoSuchElementException();
}
}

0 comments on commit 58da59e

Please sign in to comment.
You can’t perform that action at this time.