Skip to content

Commit 2ac9c7e

Browse files
committed
FELIX-6872 - Dependency Manager: ignore the harmless Config Admin message about a new factory configuration in the test base
Config Admin logs "Ignoring new configuration pid=..." at error level when a factory configuration has been created but not updated yet while the factory registers; it provides the configuration with the update. The test base fails a test when an error is logged, so this message failed an otherwise passing runtime integration test now and then on the CI runners. The test bases ignore this one message, every other logged error still fails the test. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017MGDWAYvWioowRTBkoQPjA
1 parent 2235630 commit 2ac9c7e

3 files changed

Lines changed: 42 additions & 15 deletions

File tree

  • dependencymanager
    • org.apache.felix.dependencymanager.index.itest/src/org/apache/felix/dm/index/itest/tests
    • org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/util
    • org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest

‎dependencymanager/org.apache.felix.dependencymanager.index.itest/src/org/apache/felix/dm/index/itest/tests/TestBase.java‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,14 @@ public <L extends org.osgi.service.log.Logger> L getLogger(Class<?> clazz, Class
249249
}
250250

251251
public void log(int level, String message) {
252-
checkError(level, null);
252+
checkError(level, message, null);
253253
if (LOG_LEVEL >= level) {
254254
System.out.println(getLevel(level) + " - " + Thread.currentThread().getName() + " : " + message);
255255
}
256256
}
257257

258258
public void log(int level, String message, Throwable exception) {
259-
checkError(level, exception);
259+
checkError(level, message, exception);
260260
if (LOG_LEVEL >= level) {
261261
StringBuilder sb = new StringBuilder();
262262
sb.append(getLevel(level) + " - " + Thread.currentThread().getName() + " : ");
@@ -267,7 +267,7 @@ public void log(int level, String message, Throwable exception) {
267267
}
268268

269269
public void log(ServiceReference sr, int level, String message) {
270-
checkError(level, null);
270+
checkError(level, message, null);
271271
if (LOG_LEVEL >= level) {
272272
StringBuilder sb = new StringBuilder();
273273
sb.append(getLevel(level) + " - " + Thread.currentThread().getName() + " : ");
@@ -277,7 +277,7 @@ public void log(ServiceReference sr, int level, String message) {
277277
}
278278

279279
public void log(ServiceReference sr, int level, String message, Throwable exception) {
280-
checkError(level, exception);
280+
checkError(level, message, exception);
281281
if (LOG_LEVEL >= level) {
282282
StringBuilder sb = new StringBuilder();
283283
sb.append(getLevel(level) + " - " + Thread.currentThread().getName() + " : ");
@@ -317,7 +317,16 @@ private String getLevel(int level) {
317317
}
318318
}
319319

320-
private void checkError(int level, Throwable exception) {
320+
// Config Admin logs this at error level when a factory configuration has been created but not updated yet
321+
// while the factory registers. It provides the configuration with the update, so it is not an error.
322+
private static boolean isIgnoredMessage(String message) {
323+
return message != null && message.startsWith("Ignoring new configuration pid=");
324+
}
325+
326+
private void checkError(int level, String message, Throwable exception) {
327+
if (isIgnoredMessage(message) && exception == null) {
328+
return;
329+
}
321330
if (level <= LOG_ERROR) {
322331
m_errorsLogged = true;
323332
}

‎dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/util/TestBase.java‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,14 @@ public <L extends org.osgi.service.log.Logger> L getLogger(Class<?> clazz, Class
248248
}
249249

250250
public void log(int level, String message) {
251-
checkError(level, null);
251+
checkError(level, message, null);
252252
if (LOG_LEVEL >= level) {
253253
System.out.println(getLevel(level) + " - " + Thread.currentThread().getName() + " : " + message);
254254
}
255255
}
256256

257257
public void log(int level, String message, Throwable exception) {
258-
checkError(level, exception);
258+
checkError(level, message, exception);
259259
if (LOG_LEVEL >= level) {
260260
StringBuilder sb = new StringBuilder();
261261
sb.append(getLevel(level) + " - " + Thread.currentThread().getName() + " : ");
@@ -266,7 +266,7 @@ public void log(int level, String message, Throwable exception) {
266266
}
267267

268268
public void log(ServiceReference sr, int level, String message) {
269-
checkError(level, null);
269+
checkError(level, message, null);
270270
if (LOG_LEVEL >= level) {
271271
StringBuilder sb = new StringBuilder();
272272
sb.append(getLevel(level) + " - " + Thread.currentThread().getName() + " : ");
@@ -276,7 +276,7 @@ public void log(ServiceReference sr, int level, String message) {
276276
}
277277

278278
public void log(ServiceReference sr, int level, String message, Throwable exception) {
279-
checkError(level, exception);
279+
checkError(level, message, exception);
280280
if (LOG_LEVEL >= level) {
281281
StringBuilder sb = new StringBuilder();
282282
sb.append(getLevel(level) + " - " + Thread.currentThread().getName() + " : ");
@@ -316,7 +316,16 @@ private String getLevel(int level) {
316316
}
317317
}
318318

319-
private void checkError(int level, Throwable exception) {
319+
// Config Admin logs this at error level when a factory configuration has been created but not updated yet
320+
// while the factory registers. It provides the configuration with the update, so it is not an error.
321+
private static boolean isIgnoredMessage(String message) {
322+
return message != null && message.startsWith("Ignoring new configuration pid=");
323+
}
324+
325+
private void checkError(int level, String message, Throwable exception) {
326+
if (isIgnoredMessage(message) && exception == null) {
327+
return;
328+
}
320329
if (level <= LOG_ERROR) {
321330
m_errorsLogged = true;
322331
}

‎dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/TestBase.java‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,14 @@ public <L extends org.osgi.service.log.Logger> L getLogger(Class<?> clazz, Class
242242
}
243243

244244
public void log(int level, String message) {
245-
checkError(level, null);
245+
checkError(level, message, null);
246246
if (LOG_LEVEL >= level) {
247247
System.out.println(getLevel(level) + " - " + Thread.currentThread().getName() + " : " + message);
248248
}
249249
}
250250

251251
public void log(int level, String message, Throwable exception) {
252-
checkError(level, exception);
252+
checkError(level, message, exception);
253253
if (LOG_LEVEL >= level) {
254254
StringBuilder sb = new StringBuilder();
255255
sb.append(getLevel(level) + " - " + Thread.currentThread().getName() + " : ");
@@ -261,7 +261,7 @@ public void log(int level, String message, Throwable exception) {
261261

262262
@SuppressWarnings("rawtypes")
263263
public void log(ServiceReference sr, int level, String message) {
264-
checkError(level, null);
264+
checkError(level, message, null);
265265
if (LOG_LEVEL >= level) {
266266
StringBuilder sb = new StringBuilder();
267267
sb.append(getLevel(level) + " - " + Thread.currentThread().getName() + " : ");
@@ -272,7 +272,7 @@ public void log(ServiceReference sr, int level, String message) {
272272

273273
@SuppressWarnings("rawtypes")
274274
public void log(ServiceReference sr, int level, String message, Throwable exception) {
275-
checkError(level, exception);
275+
checkError(level, message, exception);
276276
if (LOG_LEVEL >= level) {
277277
StringBuilder sb = new StringBuilder();
278278
sb.append(getLevel(level) + " - " + Thread.currentThread().getName() + " : ");
@@ -312,7 +312,16 @@ private String getLevel(int level) {
312312
}
313313
}
314314

315-
private void checkError(int level, Throwable exception) {
315+
// Config Admin logs this at error level when a factory configuration has been created but not updated yet
316+
// while the factory registers. It provides the configuration with the update, so it is not an error.
317+
private static boolean isIgnoredMessage(String message) {
318+
return message != null && message.startsWith("Ignoring new configuration pid=");
319+
}
320+
321+
private void checkError(int level, String message, Throwable exception) {
322+
if (isIgnoredMessage(message) && exception == null) {
323+
return;
324+
}
316325
if (level <= LOG_ERROR) {
317326
m_errorsLogged = true;
318327
}

0 commit comments

Comments
 (0)