You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2022/03/22 06:25:09 UTC
[felix-dev] branch master updated: FELIX-6513 : Run timer thread as a daemon thread
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/master by this push:
new b6ae88f FELIX-6513 : Run timer thread as a daemon thread
b6ae88f is described below
commit b6ae88f39e7e3e22f18d47a073a1209e46e5f3c2
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Mar 22 07:24:54 2022 +0100
FELIX-6513 : Run timer thread as a daemon thread
---
.../internal/service/HttpServiceRuntimeImpl.java | 19 ++++++--
.../internal/service/HttpServiceRuntimeImpl.java | 56 ++++++++++++----------
2 files changed, 45 insertions(+), 30 deletions(-)
diff --git a/http/base-4.x/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceRuntimeImpl.java b/http/base-4.x/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceRuntimeImpl.java
index bc822f5..101350a 100644
--- a/http/base-4.x/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceRuntimeImpl.java
+++ b/http/base-4.x/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceRuntimeImpl.java
@@ -169,7 +169,15 @@ public final class HttpServiceRuntimeImpl implements HttpServiceRuntime
}
this.serviceReg = null;
}
- this.serviceRefDTO = null;
+ synchronized ( changeCountTimerLock )
+ {
+ if ( this.changeCountTimer != null )
+ {
+ this.changeCountTimer.cancel();
+ this.changeCountTimer = null;
+ }
+ }
+ this.serviceRefDTO = null;
}
public ServiceReference<HttpServiceRuntime> getServiceReference()
@@ -206,7 +214,7 @@ public final class HttpServiceRuntimeImpl implements HttpServiceRuntime
final Timer timer;
synchronized ( this.changeCountTimerLock ) {
if ( this.changeCountTimer == null ) {
- this.changeCountTimer = new Timer();
+ this.changeCountTimer = new Timer("Apache Felix Http Runtime Timer", true);
}
timer = this.changeCountTimer;
}
@@ -232,8 +240,11 @@ public final class HttpServiceRuntimeImpl implements HttpServiceRuntime
{
if ( changeCount.get() == count )
{
- changeCountTimer.cancel();
- changeCountTimer = null;
+ if ( changeCountTimer != null )
+ {
+ changeCountTimer.cancel();
+ changeCountTimer = null;
+ }
}
}
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceRuntimeImpl.java b/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceRuntimeImpl.java
index d794f73..c1c0c5e 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceRuntimeImpl.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceRuntimeImpl.java
@@ -151,7 +151,15 @@ public final class HttpServiceRuntimeImpl implements HttpServiceRuntime
{
// we just ignore it
}
- this.serviceReg = null;
+ synchronized ( changeCountTimerLock )
+ {
+ if ( this.changeCountTimer != null )
+ {
+ this.changeCountTimer.cancel();
+ this.changeCountTimer = null;
+ }
+ }
+ this.serviceReg = null;
}
if ( this.javaxServiceReg != null )
{
@@ -181,7 +189,7 @@ public final class HttpServiceRuntimeImpl implements HttpServiceRuntime
{
final ServiceRegistration<HttpServiceRuntime> reg = this.serviceReg;
final ServiceRegistration<org.osgi.service.http.runtime.HttpServiceRuntime> javaxReg = this.javaxServiceReg;
- if ( reg != null )
+ if ( reg != null && javaxReg != null)
{
final long count = this.changeCount.incrementAndGet();
@@ -196,16 +204,13 @@ public final class HttpServiceRuntimeImpl implements HttpServiceRuntime
{
// we ignore this as this might happen on shutdown
}
- if ( javaxReg != null )
+ try
{
- try
- {
- javaxReg.setProperties(attributes);
- }
- catch ( final IllegalStateException ise)
- {
- // we ignore this as this might happen on shutdown
- }
+ javaxReg.setProperties(attributes);
+ }
+ catch ( final IllegalStateException ise)
+ {
+ // we ignore this as this might happen on shutdown
}
}
else
@@ -213,7 +218,7 @@ public final class HttpServiceRuntimeImpl implements HttpServiceRuntime
final Timer timer;
synchronized ( this.changeCountTimerLock ) {
if ( this.changeCountTimer == null ) {
- this.changeCountTimer = new Timer();
+ this.changeCountTimer = new Timer("Apache Felix Http Runtime Timer", true);
}
timer = this.changeCountTimer;
}
@@ -235,26 +240,25 @@ public final class HttpServiceRuntimeImpl implements HttpServiceRuntime
{
// we ignore this as this might happen on shutdown
}
- synchronized ( changeCountTimerLock )
+ try
{
- if ( changeCount.get() == count )
- {
- changeCountTimer.cancel();
- changeCountTimer = null;
- }
+ javaxReg.setProperties(attributes);
}
- if ( javaxReg != null )
+ catch ( final IllegalStateException ise)
{
- try
- {
- javaxReg.setProperties(attributes);
- }
- catch ( final IllegalStateException ise)
+ // we ignore this as this might happen on shutdown
+ }
+ synchronized ( changeCountTimerLock )
+ {
+ if ( changeCount.get() == count )
{
- // we ignore this as this might happen on shutdown
+ if ( changeCountTimer != null )
+ {
+ changeCountTimer.cancel();
+ changeCountTimer = null;
+ }
}
}
-
}
}
}, this.updateChangeCountDelay);