### Question:
GarbageCollectorThread extends SafeRunnable { protected void compactEntryLog(EntryLogMetadata entryLogMeta) { if (!compacting.compareAndSet(false, true)) { return; } try { compactor.compact(entryLogMeta); } catch (Exception e) { LOG.error("Failed to compact entry log {} due to unexpected error", entryLogMeta.getEntryLogId(), e); } finally { compacting.set(false); } } GarbageCollectorThread(ServerConfiguration conf, LedgerManager ledgerManager,
            final CompactableLedgerStorage ledgerStorage, StatsLogger statsLogger);  GarbageCollectorThread(ServerConfiguration conf,
                                  LedgerManager ledgerManager,
                                  final CompactableLedgerStorage ledgerStorage,
                                  StatsLogger statsLogger,
                                  ScheduledExecutorService gcExecutor); void enableForceGC(); void disableForceGC(); boolean isInForceGC(); void suspendMajorGC(); void resumeMajorGC(); void suspendMinorGC(); void resumeMinorGC(); void start(); @Override void safeRun(); void runWithFlags(boolean force, boolean suspendMajor, boolean suspendMinor); void shutdown(); GarbageCollectionStatus getGarbageCollectionStatus();  }### Answer:
@Test public void testCompactEntryLogWithException() throws Exception { AbstractLogCompactor mockCompactor = mock(AbstractLogCompactor.class); when(mockCompactor.compact(any(EntryLogMetadata.class))) .thenThrow(new RuntimeException("Unexpected compaction error")); Whitebox.setInternalState(mockGCThread, "compactor", mockCompactor); AtomicBoolean compacting = Whitebox.getInternalState(mockGCThread, "compacting"); assertFalse(compacting.get()); mockGCThread.compactEntryLog(new EntryLogMetadata(9999)); assertFalse(compacting.get()); }