use of org.apache.commons.lang3.mutable.MutableBoolean in project fmv by f-agu.
the class AAC_ADTSTOASCBitStreamFilterFFExecFallback method prepare.
/**
* @see org.fagu.fmv.ffmpeg.executor.FFExecFallback#prepare(java.io.IOException)
*/
@Override
public boolean prepare(FFEnv ffEnv, IOException ioException) throws IOException {
FFExecutor<Object> executor = ffEnv.getExecutor();
MutableBoolean change = new MutableBoolean(false);
ffEnv.getOperation().getOutputProcessorStream().forEach(outputProcessor -> {
for (String line : executor.getOutputReadLine().getLines()) {
if (line.contains("'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc'")) {
outputProcessor.bitStream(Type.AUDIO, BitStreamFilter.AAC_ADTSTOASC);
change.setTrue();
}
}
});
return change.booleanValue();
}
use of org.apache.commons.lang3.mutable.MutableBoolean in project neo4j by neo4j.
the class MuninnPageCacheTest method pageCacheFlushAndForceMustClearBackgroundEvictionException.
@Test
void pageCacheFlushAndForceMustClearBackgroundEvictionException() {
assertTimeoutPreemptively(ofMillis(SEMI_LONG_TIMEOUT_MILLIS), () -> {
MutableBoolean throwException = new MutableBoolean(true);
FileSystemAbstraction fs = new DelegatingFileSystemAbstraction(this.fs) {
@Override
public StoreChannel open(Path fileName, Set<OpenOption> options) throws IOException {
return new DelegatingStoreChannel(super.open(fileName, options)) {
@Override
public void writeAll(ByteBuffer src, long position) throws IOException {
if (throwException.booleanValue()) {
throw new IOException("uh-oh...");
} else {
super.writeAll(src, position);
}
}
};
}
};
try (MuninnPageCache pageCache = createPageCache(fs, 2, PageCacheTracer.NULL);
PagedFile pagedFile = map(pageCache, file("a"), 8)) {
try (PageCursor cursor = pagedFile.io(0, PF_SHARED_WRITE_LOCK, NULL)) {
// Page 0 is now dirty, but flushing it will throw an exception.
assertTrue(cursor.next());
}
// This will run into that exception, in background eviction:
pageCache.evictPages(1, 0, EvictionRunEvent.NULL);
// We now have a background eviction exception. A successful flushAndForce should clear it, though.
throwException.setFalse();
pageCache.flushAndForce();
// And with a cleared exception, we should be able to work with the page cache without worry.
try (PageCursor cursor = pagedFile.io(0, PF_SHARED_WRITE_LOCK, NULL)) {
for (int i = 0; i < maxPages * 20; i++) {
assertTrue(cursor.next());
}
}
}
});
}
use of org.apache.commons.lang3.mutable.MutableBoolean in project midpoint by Evolveum.
the class ValuePolicyProcessor method checkProhibitedValues.
private <O extends ObjectType, R extends ObjectType> boolean checkProhibitedValues(String newPassword, ProhibitedValuesType prohibitedValuesType, ObjectBasedValuePolicyOriginResolver<O> originResolver, Consumer<ProhibitedValueItemType> failAction, String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
if (prohibitedValuesType == null || originResolver == null) {
return true;
}
MutableBoolean isAcceptable = new MutableBoolean(true);
for (ProhibitedValueItemType prohibitedItemType : prohibitedValuesType.getItem()) {
ItemPathType itemPathType = prohibitedItemType.getPath();
if (itemPathType == null) {
throw new SchemaException("No item path defined in prohibited item in " + shortDesc);
}
ItemPath itemPath = itemPathType.getItemPath();
ResultHandler<R> handler = (object, objectResult) -> {
PrismProperty<Object> objectProperty = object.findProperty(itemPath);
if (objectProperty == null) {
return true;
}
if (isMatching(newPassword, objectProperty)) {
if (failAction != null) {
failAction.accept(prohibitedItemType);
}
isAcceptable.setValue(false);
return false;
}
return true;
};
originResolver.resolve(prohibitedItemType, handler, shortDesc, task, result);
}
return isAcceptable.booleanValue();
}
use of org.apache.commons.lang3.mutable.MutableBoolean in project druid by druid-io.
the class FilteringCloseableInputRowIteratorTest method testCloseDelegateIsClosed.
@Test
public void testCloseDelegateIsClosed() throws IOException {
final MutableBoolean closed = new MutableBoolean(false);
final CloseableIterator<InputRow> delegate = CloseableIterators.wrap(Collections.emptyIterator(), closed::setTrue);
final FilteringCloseableInputRowIterator rowIterator = new FilteringCloseableInputRowIterator(delegate, row -> true, rowIngestionMeters, parseExceptionHandler);
rowIterator.close();
Assert.assertTrue(closed.isTrue());
}
use of org.apache.commons.lang3.mutable.MutableBoolean in project druid by druid-io.
the class ServerManagerForQueryErrorTest method buildQueryRunnerForSegment.
@Override
protected <T> QueryRunner<T> buildQueryRunnerForSegment(Query<T> query, SegmentDescriptor descriptor, QueryRunnerFactory<T, Query<T>> factory, QueryToolChest<T, Query<T>> toolChest, VersionedIntervalTimeline<String, ReferenceCountingSegment> timeline, Function<SegmentReference, SegmentReference> segmentMapFn, AtomicLong cpuTimeAccumulator, Optional<byte[]> cacheKeyPrefix) {
if (query.getContextBoolean(QUERY_RETRY_TEST_CONTEXT_KEY, false)) {
final MutableBoolean isIgnoreSegment = new MutableBoolean(false);
queryToIgnoredSegments.compute(query.getMostSpecificId(), (queryId, ignoredSegments) -> {
if (ignoredSegments == null) {
ignoredSegments = new HashSet<>();
}
if (ignoredSegments.size() < MAX_NUM_FALSE_MISSING_SEGMENTS_REPORTS) {
ignoredSegments.add(descriptor);
isIgnoreSegment.setTrue();
}
return ignoredSegments;
});
if (isIgnoreSegment.isTrue()) {
LOG.info("Pretending I don't have segment[%s]", descriptor);
return new ReportTimelineMissingSegmentQueryRunner<>(descriptor);
}
} else if (query.getContextBoolean(QUERY_TIMEOUT_TEST_CONTEXT_KEY, false)) {
return (queryPlus, responseContext) -> new Sequence<T>() {
@Override
public <OutType> OutType accumulate(OutType initValue, Accumulator<OutType, T> accumulator) {
throw new QueryTimeoutException("query timeout test");
}
@Override
public <OutType> Yielder<OutType> toYielder(OutType initValue, YieldingAccumulator<OutType, T> accumulator) {
throw new QueryTimeoutException("query timeout test");
}
};
} else if (query.getContextBoolean(QUERY_CAPACITY_EXCEEDED_TEST_CONTEXT_KEY, false)) {
return (queryPlus, responseContext) -> new Sequence<T>() {
@Override
public <OutType> OutType accumulate(OutType initValue, Accumulator<OutType, T> accumulator) {
throw QueryCapacityExceededException.withErrorMessageAndResolvedHost("query capacity exceeded test");
}
@Override
public <OutType> Yielder<OutType> toYielder(OutType initValue, YieldingAccumulator<OutType, T> accumulator) {
throw QueryCapacityExceededException.withErrorMessageAndResolvedHost("query capacity exceeded test");
}
};
} else if (query.getContextBoolean(QUERY_UNSUPPORTED_TEST_CONTEXT_KEY, false)) {
return (queryPlus, responseContext) -> new Sequence<T>() {
@Override
public <OutType> OutType accumulate(OutType initValue, Accumulator<OutType, T> accumulator) {
throw new QueryUnsupportedException("query unsupported test");
}
@Override
public <OutType> Yielder<OutType> toYielder(OutType initValue, YieldingAccumulator<OutType, T> accumulator) {
throw new QueryUnsupportedException("query unsupported test");
}
};
} else if (query.getContextBoolean(RESOURCE_LIMIT_EXCEEDED_TEST_CONTEXT_KEY, false)) {
return (queryPlus, responseContext) -> new Sequence<T>() {
@Override
public <OutType> OutType accumulate(OutType initValue, Accumulator<OutType, T> accumulator) {
throw new ResourceLimitExceededException("resource limit exceeded test");
}
@Override
public <OutType> Yielder<OutType> toYielder(OutType initValue, YieldingAccumulator<OutType, T> accumulator) {
throw new ResourceLimitExceededException("resource limit exceeded test");
}
};
} else if (query.getContextBoolean(QUERY_FAILURE_TEST_CONTEXT_KEY, false)) {
return (queryPlus, responseContext) -> new Sequence<T>() {
@Override
public <OutType> OutType accumulate(OutType initValue, Accumulator<OutType, T> accumulator) {
throw new RuntimeException("query failure test");
}
@Override
public <OutType> Yielder<OutType> toYielder(OutType initValue, YieldingAccumulator<OutType, T> accumulator) {
throw new RuntimeException("query failure test");
}
};
}
return super.buildQueryRunnerForSegment(query, descriptor, factory, toolChest, timeline, segmentMapFn, cpuTimeAccumulator, cacheKeyPrefix);
}
Aggregations