Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
base repository: wildfly/wildfly
Choose a Base Repository
wildfly/wildfly
2002simon01/jboss-as
ALRubinger/wildfly
ErikWRasmussen/jboss-as
KurtStam/jboss-as
Lerm/jboss-as
LinuxEvangelist/jboss-as
Mogztter/wildfly
OndraZizka/jboss-as
PayU-EMEA/jboss-as
aaronwalker/jboss-as
agibsonccc/jboss-as
akalachm/jboss-as
alesj/jboss-as
alns/jboss-as
aloubyansky/wildfly
aminorex/jboss-as
andersnorgaard/jboss-as
andredemathe/jboss-as
andytaylor/wildfly
aprilhu0/jboss-as
ashields/jboss-as
aslakknutsen/jboss-as
asoldano/wildfly
awirayaksa/jboss-as
bershath/jboss-as
bgeorges/jboss-as
blue61/jboss-as
bosschaert/jboss-as
bstansberry/wildfly
btison/jboss-as
cbue/jboss-as
charleswmiller/jboss-as
chikin/jboss-as
chriskriel/jboss-as
coberle/jboss-as
colmsean/jboss-as
ctomc/wildfly
dandreadis/wildfly
darranl/wildfly
dcaillia/jboss-as
denuno/jboss-as
deruelle/jboss-as
dhollandAtWex/dh-old-forks-jboss-as
dmlloyd/wildfly
dobozysaurus/jboss-as
dpospisil/wildfly
edbean/jboss-as
emannuel/jboss-as
emerile1/jboss-as
emuckenhuber/wildfly
esantana/jboss-as
fbricon/jboss-as
fedora-jboss-as/wildfly
fei-yin/jboss-as
fharms/wildfly
fregaham/jboss-as
fxlambda-twickly5/wildfly
garcimouche/jboss-as
goldmann/jboss-as
gonne/jboss-as
gvagenas/jboss-as
hamanju/jboss-as
hamming229/jboss-as
heiko-braun/wildfly
hgkmiracle/jboss-as
hunter-thom/jboss-as
ikaro/jboss-as
istudens/wildfly
jaikiran/wildfly
jamezp/wildfly
janpiel/jboss-as
java-coder/jboss-as
jayhowell/jboss-as
jbossejb3/jboss-as
jdmr/jboss-as
jdpgrailsdev/jboss-as
jeenapeter/jboss-as
jeffzhang/jboss-as
jeremiahshirk/jboss-as
jiwils/jboss-as
jlindesmith/jboss-as
jmartisk/wildfly
jocstar/jboss-as
joseph2000/jboss-as
jrwhitley/jboss-as
jswordfish/jboss-as
jtoerber/jboss-as
julianzhu/jboss-as
jwulf/jboss-as
kabir/wildfly
kbys/jboss-as
koledzhikov/jboss-as
kpiwko/wildfly
kylape/wildfly
ldevrie/jboss-as
lingling788/jboss-as
liweinan/jboss-as
luksa/wildfly
lydonchandra/jboss-as
maasvdberg/wildfly
madhumita/jboss-as
madhumita12/jboss-as
maerqiang/jboss-as
maeste/jboss-as
mageshbk/jboss-as
markmc/jboss-as
markyour/jboss-as
maschmid/jboss-as
matejonnet/jboss-as
mathieuancelin/jboss-as
mathieufortin01/jboss-as
mattdrees/jboss-as
maxandersen/jboss-as
maximilienw/jboss-as
mbogoevici/jboss-as
mbrasier/jboss-as
mdemerath/jboss-as
mgencur/jboss-as
michaelschuetz/jboss-as
miclark/jboss-as
migue/wildfly
mikebrock/jboss-as
mkiman/jboss-as
mlinhard/jboss-as
mmoyses/jboss-as
mojavelinux/jboss-as
mschwartzman/jboss-as
mstruk/jboss-as
nikkack/jboss-as
nookala/jboss-as
npfr/jboss-as
nscavell/jboss-as
ochaloup/wildfly
patmcdonough/jboss-as
pbielicki/jboss-as
pentarou/jboss-as
pepite/jboss-as
petbac/jboss-as
pferraro/wildfly
pmf8/jboss-as
pmuir/jboss-as
porobd/jboss-as
prabugp/jboss-as
pragnesh/jboss-as
prasad-deshpande/jboss-as
prcg66/jboss-as
pskopek/wildfly
pslegr/jboss-as
rachmatowicz/wildfly
rachmatowicz2/jboss-as
randythomas/jboss-as
rhusar/wildfly
richmidwinter/jboss-as
richsharples/jboss-as
ringerc/jboss-as
robertpanzer/jboss-as
robstryker/jboss-as
rsvoboda/wildfly
rzimmermann/jboss-as
sacdroid/jboss-as
samuelo/jboss-as
sasgww/jboss-as
scottmarlow/wildfly
sebersole/jboss-as
seeburger-ag/jboss-as
seko2000/jboss-as
sgilda/wildfly
shadangi/jboss-as
shuawest/jboss-as
sjancke/jboss-as
skoussou/jboss-as
smcgowan/wildfly
spreadline/jboss-as
ssilvert/wildfly
starksm64/jboss-as
starksmjboss/jboss-as
stliu/jboss-as
stuartwdouglas/wildfly
sujaybawaskar/jboss-as
tdiesler/wildfly
tfennelly/jboss-as
thammoud/jboss-as
thanhvc/jboss-as
thauser/jboss-as
thomasnymand/jboss-as
thunderlei/jboss-as
tomathome/jboss-as
tomwells/jboss-as
tristantarrant/wildfly
tyasuma/jboss-as
undertow-io/jboss-as
vladimirralev/jboss-as
vmariusvv/jboss-as
vratsel/jboss-as
weld/wildfly
wfink/wildfly
wolfc/jboss-as
zhigunovs/jboss-as
zhleonix/jboss-as
Nothing to show
base: 10dc57c
head repository: wildfly/wildfly
Choose a Head Repository
wildfly/wildfly
2002simon01/jboss-as
ALRubinger/wildfly
ErikWRasmussen/jboss-as
KurtStam/jboss-as
Lerm/jboss-as
LinuxEvangelist/jboss-as
Mogztter/wildfly
OndraZizka/jboss-as
PayU-EMEA/jboss-as
aaronwalker/jboss-as
agibsonccc/jboss-as
akalachm/jboss-as
alesj/jboss-as
alns/jboss-as
aloubyansky/wildfly
aminorex/jboss-as
andersnorgaard/jboss-as
andredemathe/jboss-as
andytaylor/wildfly
aprilhu0/jboss-as
ashields/jboss-as
aslakknutsen/jboss-as
asoldano/wildfly
awirayaksa/jboss-as
bershath/jboss-as
bgeorges/jboss-as
blue61/jboss-as
bosschaert/jboss-as
bstansberry/wildfly
btison/jboss-as
cbue/jboss-as
charleswmiller/jboss-as
chikin/jboss-as
chriskriel/jboss-as
coberle/jboss-as
colmsean/jboss-as
ctomc/wildfly
dandreadis/wildfly
darranl/wildfly
dcaillia/jboss-as
denuno/jboss-as
deruelle/jboss-as
dhollandAtWex/dh-old-forks-jboss-as
dmlloyd/wildfly
dobozysaurus/jboss-as
dpospisil/wildfly
edbean/jboss-as
emannuel/jboss-as
emerile1/jboss-as
emuckenhuber/wildfly
esantana/jboss-as
fbricon/jboss-as
fedora-jboss-as/wildfly
fei-yin/jboss-as
fharms/wildfly
fregaham/jboss-as
fxlambda-twickly5/wildfly
garcimouche/jboss-as
goldmann/jboss-as
gonne/jboss-as
gvagenas/jboss-as
hamanju/jboss-as
hamming229/jboss-as
heiko-braun/wildfly
hgkmiracle/jboss-as
hunter-thom/jboss-as
ikaro/jboss-as
istudens/wildfly
jaikiran/wildfly
jamezp/wildfly
janpiel/jboss-as
java-coder/jboss-as
jayhowell/jboss-as
jbossejb3/jboss-as
jdmr/jboss-as
jdpgrailsdev/jboss-as
jeenapeter/jboss-as
jeffzhang/jboss-as
jeremiahshirk/jboss-as
jiwils/jboss-as
jlindesmith/jboss-as
jmartisk/wildfly
jocstar/jboss-as
joseph2000/jboss-as
jrwhitley/jboss-as
jswordfish/jboss-as
jtoerber/jboss-as
julianzhu/jboss-as
jwulf/jboss-as
kabir/wildfly
kbys/jboss-as
koledzhikov/jboss-as
kpiwko/wildfly
kylape/wildfly
ldevrie/jboss-as
lingling788/jboss-as
liweinan/jboss-as
luksa/wildfly
lydonchandra/jboss-as
maasvdberg/wildfly
madhumita/jboss-as
madhumita12/jboss-as
maerqiang/jboss-as
maeste/jboss-as
mageshbk/jboss-as
markmc/jboss-as
markyour/jboss-as
maschmid/jboss-as
matejonnet/jboss-as
mathieuancelin/jboss-as
mathieufortin01/jboss-as
mattdrees/jboss-as
maxandersen/jboss-as
maximilienw/jboss-as
mbogoevici/jboss-as
mbrasier/jboss-as
mdemerath/jboss-as
mgencur/jboss-as
michaelschuetz/jboss-as
miclark/jboss-as
migue/wildfly
mikebrock/jboss-as
mkiman/jboss-as
mlinhard/jboss-as
mmoyses/jboss-as
mojavelinux/jboss-as
mschwartzman/jboss-as
mstruk/jboss-as
nikkack/jboss-as
nookala/jboss-as
npfr/jboss-as
nscavell/jboss-as
ochaloup/wildfly
patmcdonough/jboss-as
pbielicki/jboss-as
pentarou/jboss-as
pepite/jboss-as
petbac/jboss-as
pferraro/wildfly
pmf8/jboss-as
pmuir/jboss-as
porobd/jboss-as
prabugp/jboss-as
pragnesh/jboss-as
prasad-deshpande/jboss-as
prcg66/jboss-as
pskopek/wildfly
pslegr/jboss-as
rachmatowicz/wildfly
rachmatowicz2/jboss-as
randythomas/jboss-as
rhusar/wildfly
richmidwinter/jboss-as
richsharples/jboss-as
ringerc/jboss-as
robertpanzer/jboss-as
robstryker/jboss-as
rsvoboda/wildfly
rzimmermann/jboss-as
sacdroid/jboss-as
samuelo/jboss-as
sasgww/jboss-as
scottmarlow/wildfly
sebersole/jboss-as
seeburger-ag/jboss-as
seko2000/jboss-as
sgilda/wildfly
shadangi/jboss-as
shuawest/jboss-as
sjancke/jboss-as
skoussou/jboss-as
smcgowan/wildfly
spreadline/jboss-as
ssilvert/wildfly
starksm64/jboss-as
starksmjboss/jboss-as
stliu/jboss-as
stuartwdouglas/wildfly
sujaybawaskar/jboss-as
tdiesler/wildfly
tfennelly/jboss-as
thammoud/jboss-as
thanhvc/jboss-as
thauser/jboss-as
thomasnymand/jboss-as
thunderlei/jboss-as
tomathome/jboss-as
tomwells/jboss-as
tristantarrant/wildfly
tyasuma/jboss-as
undertow-io/jboss-as
vladimirralev/jboss-as
vmariusvv/jboss-as
vratsel/jboss-as
weld/wildfly
wfink/wildfly
wolfc/jboss-as
zhigunovs/jboss-as
zhleonix/jboss-as
Nothing to show
compare: 2ee5a99
  • 3 commits
  • 10 files changed
  • 0 commit comments
  • 2 contributors
Commits on Apr 14, 2019
WFLY-11897, WFLY-11970 Fix memory leaks caused by SFSB expiration failures
@@ -21,7 +21,7 @@
*/
package org.wildfly.clustering.ejb.infinispan;

import java.util.Date;
import java.time.Instant;

/**
* The cache entry for a bean.
@@ -35,6 +35,6 @@
G getGroupId();
String getBeanName();

Date getLastAccessedTime();
void setLastAccessedTime(Date time);
Instant getLastAccessedTime();
void setLastAccessedTime(Instant time);
}
@@ -114,16 +114,22 @@ public void close() {
@Override
public void run() {
InfinispanEjbLogger.ROOT_LOGGER.tracef("Expiring stateful session bean %s", this.id);
boolean removed = false;
try (Batch batch = BeanExpirationScheduler.this.batcher.createBatch()) {
try {
BeanExpirationScheduler.this.remover.remove(this.id, BeanExpirationScheduler.this.expiration.getRemoveListener());
removed = BeanExpirationScheduler.this.remover.remove(this.id, BeanExpirationScheduler.this.expiration.getRemoveListener());
} catch (Throwable e) {
InfinispanEjbLogger.ROOT_LOGGER.failedToExpireBean(e, this.id);
batch.discard();
}
} finally {
synchronized (this) {
BeanExpirationScheduler.this.expirationFutures.remove(this.id);
if (removed) {
BeanExpirationScheduler.this.expirationFutures.remove(this.id);
} else {
// If bean failed to expire, likely due to a lock timeout, just reschedule it
BeanExpirationScheduler.this.schedule(this.id);
}
}
}
}
@@ -29,5 +29,11 @@
* @author Paul Ferraro
*/
public interface BeanRemover<K, V> {
void remove(K id, RemoveListener<V> listener);
/**
* Removes the specified bean, triggering the specified listener
* @param id a bean identifier
* @param listener a removal listener
* @return true, if the bean was (or was already) removed, false otherwise
*/
boolean remove(K id, RemoveListener<V> listener);
}
@@ -43,15 +43,17 @@ public ExpiredBeanRemover(BeanFactory<I, T> factory) {
}

@Override
public void remove(I id, RemoveListener<T> listener) {
public boolean remove(I id, RemoveListener<T> listener) {
BeanEntry<I> entry = this.factory.findValue(id);
@SuppressWarnings("resource")
Bean<I, T> bean = (entry != null) ? this.factory.createBean(id, entry) : null;
if (bean != null) {
if (bean.isExpired()) {
InfinispanEjbLogger.ROOT_LOGGER.tracef("Removing expired bean %s", id);
this.factory.remove(id, listener);
return this.factory.remove(id, listener);
}
return false;
}
return true;
}
}
@@ -22,7 +22,7 @@
package org.wildfly.clustering.ejb.infinispan.bean;

import java.time.Duration;
import java.util.Date;
import java.time.Instant;
import java.util.concurrent.atomic.AtomicBoolean;

import org.wildfly.clustering.ee.Mutator;
@@ -76,10 +76,10 @@ public I getGroupId() {

@Override
public boolean isExpired() {
if (this.timeout == null) return false;
Date lastAccessedTime = this.entry.getLastAccessedTime();
long timeout = this.timeout.toMillis();
return (lastAccessedTime != null) && (timeout > 0) ? ((System.currentTimeMillis() - lastAccessedTime.getTime()) >= timeout) : false;
if ((this.timeout == null) || this.timeout.isNegative()) return false;
if (this.timeout.isZero()) return true;
Instant lastAccessedTime = this.entry.getLastAccessedTime();
return (lastAccessedTime != null) ? !lastAccessedTime.plus(this.timeout).isAfter(Instant.now()) : false;
}

@Override
@@ -110,8 +110,8 @@ public boolean release() {
@Override
public void close() {
if (this.valid.get()) {
Date lastAccessedTime = this.entry.getLastAccessedTime();
this.entry.setLastAccessedTime(new Date());
Instant lastAccessedTime = this.entry.getLastAccessedTime();
this.entry.setLastAccessedTime(Instant.now());
if (lastAccessedTime != null) {
this.mutator.mutate();
}
@@ -23,7 +23,7 @@

import org.wildfly.clustering.ejb.infinispan.BeanEntry;

import java.util.Date;
import java.time.Instant;

/**
* The cache entry for a bean.
@@ -36,7 +36,7 @@

private final String beanName;
private final I groupId;
private volatile Date lastAccessedTime;
private volatile Instant lastAccessedTime;

public InfinispanBeanEntry(String beanName, I groupId) {
this.beanName = beanName;
@@ -54,12 +54,12 @@ public I getGroupId() {
}

@Override
public Date getLastAccessedTime() {
public Instant getLastAccessedTime() {
return this.lastAccessedTime;
}

@Override
public void setLastAccessedTime(Date time) {
public void setLastAccessedTime(Instant time) {
this.lastAccessedTime = time;
}
}
@@ -24,7 +24,7 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Date;
import java.time.Instant;

import org.jboss.ejb.client.SessionID;
import org.kohsuke.MetaInfServices;
@@ -41,16 +41,16 @@
public void writeObject(ObjectOutput output, InfinispanBeanEntry<SessionID> entry) throws IOException {
output.writeUTF(entry.getBeanName());
SessionIDSerializer.INSTANCE.write(output, entry.getGroupId());
Date lastAccessedTime = entry.getLastAccessedTime();
output.writeLong((lastAccessedTime != null) ? lastAccessedTime.getTime() : 0);
Instant lastAccessedTime = entry.getLastAccessedTime();
output.writeLong((lastAccessedTime != null) ? lastAccessedTime.toEpochMilli() : 0L);
}

@Override
public InfinispanBeanEntry<SessionID> readObject(ObjectInput input) throws IOException, ClassNotFoundException {
InfinispanBeanEntry<SessionID> entry = new InfinispanBeanEntry<>(input.readUTF(), SessionIDSerializer.INSTANCE.read(input));
long time = input.readLong();
if (time > 0) {
entry.setLastAccessedTime(new Date(time));
long lastAccessedTime = input.readLong();
if (lastAccessedTime > 0L) {
entry.setLastAccessedTime(Instant.ofEpochMilli(lastAccessedTime));
}
return entry;
}
@@ -102,7 +102,7 @@ public InfinispanBeanFactory(String beanName, BeanGroupFactory<I, T> groupFactor
}

@Override
public void remove(I id, RemoveListener<T> listener) {
public boolean remove(I id, RemoveListener<T> listener) {
BeanEntry<I> entry = this.cache.getAdvancedCache().withFlags(Flag.FORCE_SYNCHRONOUS).remove(this.createKey(id));
if (entry != null) {
I groupId = entry.getGroupId();
@@ -116,5 +116,6 @@ public void remove(I id, RemoveListener<T> listener) {
}
}
}
return true;
}
}
@@ -73,6 +73,7 @@ public void testExpire() throws InterruptedException {

when(config.getTimeout()).thenReturn(Duration.ofMillis(1L));
when(config.getRemoveListener()).thenReturn(listener);
when(remover.remove(beanId, listener)).thenReturn(true);

try (Scheduler<String> scheduler = new BeanExpirationScheduler<>(batcher, remover, config)) {
scheduler.schedule(beanId);
@@ -96,6 +97,7 @@ public void testCancel() throws InterruptedException {

when(config.getTimeout()).thenReturn(Duration.ofMinutes(1L));
when(config.getRemoveListener()).thenReturn(listener);
when(remover.remove(beanId, listener)).thenReturn(true);

try (Scheduler<String> scheduler = new BeanExpirationScheduler<>(batcher, remover, config)) {
scheduler.schedule(beanId);
@@ -29,7 +29,7 @@
import static org.mockito.Mockito.when;

import java.time.Duration;
import java.util.Date;
import java.time.Instant;

import org.junit.After;
import org.junit.Assert;
@@ -93,11 +93,11 @@ public void isExpired() {
when(this.entry.getLastAccessedTime()).thenReturn(null);
Assert.assertFalse(this.bean.isExpired());

long now = System.currentTimeMillis();
when(this.entry.getLastAccessedTime()).thenReturn(new Date(now));
Instant now = Instant.now();
when(this.entry.getLastAccessedTime()).thenReturn(now);
Assert.assertFalse(this.bean.isExpired());

when(this.entry.getLastAccessedTime()).thenReturn(new Date(now - this.timeout.toMillis() - 1));
when(this.entry.getLastAccessedTime()).thenReturn(now.minus(this.timeout));
Assert.assertTrue(this.bean.isExpired());
}

@@ -123,18 +123,18 @@ public void close() {

this.bean.close();

verify(this.entry).setLastAccessedTime(ArgumentMatchers.<Date>any());
verify(this.entry).setLastAccessedTime(ArgumentMatchers.<Instant>any());
verify(this.mutator, never()).mutate();
verify(this.group, never()).close();

reset(this.entry, this.mutator, this.group);

when(this.entry.getLastAccessedTime()).thenReturn(new Date());
when(this.entry.getLastAccessedTime()).thenReturn(Instant.now());
when(this.group.isCloseable()).thenReturn(true);

this.bean.close();

verify(this.entry).setLastAccessedTime(ArgumentMatchers.<Date>any());
verify(this.entry).setLastAccessedTime(ArgumentMatchers.<Instant>any());
verify(this.mutator).mutate();
verify(this.group).close();
}

No commit comments for this range

You can’t perform that action at this time.