method2testcases
stringlengths
118
6.63k
### Question: FileBlockingQueue extends AbstractQueue<E> implements BlockingQueue<E> { @Override public Iterator<E> iterator() { return new Iterator<E>() { @Override public boolean hasNext() { return !isEmpty(); } @Override public E next() { try { E x = consumeElement(); return x; } catch (IOException e) { throw new Ru...
### Question: QueuedSink extends Thread { protected void initialize( String sinkId, MessageQueue4Sink queue4Sink, int batchSize, int batchTimeout, boolean pauseOnLongQueue) { this.sinkId = sinkId; this.queue4Sink = queue4Sink; this.batchSize = batchSize == 0 ? 1000 : batchSize; this.batchTimeout = batchTimeout == 0 ? 1...
### Question: FileNameFormatter { public static String get(String dir) { StringBuilder sb = new StringBuilder(dir); if (!dir.endsWith("/")) { sb.append('/'); } sb.append(fmt.print(new DateTime())) .append(localHostAddr) .append(new UID().toString()); return sb.toString().replaceAll("[-:]", ""); } static String get(Str...
### Question: LocalFileSink extends QueuedSink implements Sink { public int cleanUp(boolean fetchAll) { return cleanUp(outputDir, fetchAll); } @JsonCreator LocalFileSink( @JsonProperty("outputDir") String outputDir, @JsonProperty("writer") FileWriter writer, @JsonProperty("notice") ...
### Question: LocalFileSink extends QueuedSink implements Sink { public static String getFileExt(String fileName) { int dotPos = fileName.lastIndexOf('.'); if (dotPos != -1 && dotPos != fileName.length() - 1) { return fileName.substring(dotPos); } else { return null; } } @JsonCreator LocalFileSink( @JsonPr...
### Question: ElasticSearchSink extends ThreadPoolQueuedSink implements Sink { public void recover(Message message) { IndexInfo info = indexInfo.create(message); HttpResponse response = null; try { response = client.executeWithLoadBalancer( HttpRequest.newBuilder() .verb(HttpRequest.Verb.POST) .setRetriable(true) .uri(...
### Question: PathValueMessageFilter extends BaseMessageFilter { @SuppressWarnings("unchecked") @Override public boolean apply(Object input) { JXPathContext jxpath = JXPathContext.newContext(input); jxpath.setLenient(true); Object value = jxpath.getValue(xpath); return predicate.apply(value); } PathValueMessageFilter(S...
### Question: TimestampField { public long get(Map<String, Object> msg) { Object value = msg.get(fieldName); if (value instanceof Number) { return ((Number) value).longValue(); } return formatter.parser().parseMillis(value.toString()); } @JsonCreator TimestampField(@JsonProperty("field") String fieldName, @JsonPropert...
### Question: IndexSuffixFormatter { public String format(IndexInfo info) { return formatter.apply(info); } @JsonCreator IndexSuffixFormatter( @JsonProperty("type") String type, @JsonProperty("properties") Properties props); String format(IndexInfo info); }### Answer: @Test public void shouldN...
### Question: ConnectionPool { @Monitor(name = "PoolSize", type = DataSourceType.GAUGE) public int getPoolSize() { return connectionList.size(); } @Inject ConnectionPool(ClientConfig config, ILoadBalancer lb); @PreDestroy void shutdown(); @Monitor(name = "PoolSize", type = DataSourceType.GAUGE) int getPoolSize(); int ...
### Question: SuroPing extends AbstractLoadBalancerPing { public boolean isAlive(Server server) { TSocket socket = null; TFramedTransport transport = null; try { socket = new TSocket(server.getHost(), server.getPort(), 2000); socket.getSocket().setTcpNoDelay(true); socket.getSocket().setKeepAlive(true); socket.getSocke...
### Question: AsyncSuroSender implements Runnable { public void run() { boolean sent = false; boolean retried = false; long startTS = System.currentTimeMillis(); for (int i = 0; i < config.getRetryCount(); ++i) { ConnectionPool.SuroConnection connection = connectionPool.chooseConnection(); if (connection == null) { con...
### Question: AsyncSuroClient implements ISuroClient { public void restore(Message message) { restoredMessages.incrementAndGet(); DynamicCounter.increment( MonitorConfig.builder(TagKey.RESTORED_COUNT) .withTag(TagKey.APP, config.getApp()) .withTag(TagKey.DATA_SOURCE, message.getRoutingKey()) .build()); for (Listener li...
### Question: JsonLine implements RecordParser { @Override public List<MessageContainer> parse(String data) { if (routingKey != null) { return new ImmutableList.Builder<MessageContainer>() .add(new DefaultMessageContainer( new Message(routingKey, data.getBytes()), jsonMapper)) .build(); } else { try { Map<String, Objec...
### Question: GrantAcl { public GrantAcl(RestS3Service s3Service, String s3Acl, int s3AclRetries) { this.s3Service = s3Service; this.s3Acl = s3Acl; this.s3AclRetries = s3AclRetries; } GrantAcl(RestS3Service s3Service, String s3Acl, int s3AclRetries); boolean grantAcl(S3Object object); }### Answer: @Test public void te...
### Question: NullValuePredicate implements ValuePredicate { @Override public boolean apply(final Object input) { return input == null; } private NullValuePredicate(); @Override boolean apply(final Object input); @Override String toString(); @Override final int hashCode(); @Override final boolean equals(Object obj); s...
### Question: StringValuePredicate implements ValuePredicate<String> { @Override public boolean apply(@Nullable String input) { return Objects.equal(value, input); } StringValuePredicate(@Nullable String value); @Override boolean apply(@Nullable String input); @Override String toString(); @Override int hashCode(); @Ove...
### Question: LocaleChangerDelegate { void initialize() { Locale persistedLocale = persistor.load(); if (persistedLocale != null) try { currentLocale = resolver.resolve(persistedLocale); } catch (UnsupportedLocaleException e) { persistedLocale = null; } if (persistedLocale == null) { DefaultResolvedLocalePair defaultLo...
### Question: LocaleResolver { DefaultResolvedLocalePair resolveDefault() { MatchingLocales matchingPair = matchingAlgorithm.findDefaultMatch(supportedLocales, systemLocales); return matchingPair != null ? new DefaultResolvedLocalePair(matchingPair.getSupportedLocale(), matchingPair.getPreferredLocale(preference)) : ne...
### Question: LocaleResolver { Locale resolve(Locale supportedLocale) throws UnsupportedLocaleException { if (!supportedLocales.contains(supportedLocale)) throw new UnsupportedLocaleException("The Locale you are trying to load is not in the supported list provided on library initialization"); MatchingLocales matchingPa...
### Question: LocaleChangerDelegate { void setLocale(Locale supportedLocale) { try { currentLocale = resolver.resolve(supportedLocale); persistor.save(supportedLocale); appLocaleChanger.change(currentLocale); } catch (UnsupportedLocaleException e) { throw new IllegalArgumentException(e); } } LocaleChangerDelegate(Local...
### Question: LocaleChangerDelegate { Locale getLocale() { return persistor.load(); } LocaleChangerDelegate(LocalePersistor persistor, LocaleResolver resolver, AppLocaleChanger appLocaleChanger); }### Answer: @Test public void ShouldLoadPersistedLocale_WhenGetCurren...
### Question: LibraryDBDao implements Serializable { public void destoryDB() { mDbOpenHelper = null; DataBaseOpenHelper.clearInstance(); } LibraryDBDao(Context context); void destoryDB(); boolean addBook(Book book); List<Book> queryAllBookList(); void updateBookInfo(String id, Book book); List<Book> searchBooks(String ...
### Question: BatchEnvironment extends org.glassfish.rmic.tools.javac.BatchEnvironment { public static ClassPath createClassPath(String classPathString, String sysClassPathString) { Path path = new Path(); if (sysClassPathString == null) { sysClassPathString = System.getProperty("sun.boot.class.path"); } if (sysClassPa...
### Question: TypeFactory { static Type createMethodType(String descriptor) { org.objectweb.asm.Type returnType = org.objectweb.asm.Type.getReturnType(descriptor); return Type.tMethod(toRmicType(returnType), toTypeArray(org.objectweb.asm.Type.getArgumentTypes(descriptor))); } }### Answer: @Test public void construct...
### Question: TypeFactory { static Type createType(String descriptor) { return toRmicType(org.objectweb.asm.Type.getType(descriptor)); } }### Answer: @Test public void constructMultiDimensionalArrayType() throws Exception { assertThat(TypeFactory.createType("[[I"), equalTo(Type.tArray(Type.tArray(Type.tInt)))); }
### Question: Main implements org.glassfish.rmic.Constants { boolean displayErrors(BatchEnvironment env) { List<String> summary = new ArrayList<>(); if (env.nerrors > 0) summary.add(getErrorSummary(env)); if (env.nwarnings > 0) summary.add(getWarningSummary(env)); if (!summary.isEmpty()) output(String.join(", ", summar...
### Question: ClientRequestDispatcherImpl implements ClientRequestDispatcher { @Subcontract public CDRInputObject marshalingComplete(java.lang.Object self, CDROutputObject outputObject) throws ApplicationException, org.omg.CORBA.portable.RemarshalException { MessageMediator messageMediator = outputObject.getMes...
### Question: StubInvocationHandlerImpl implements LinkedInvocationHandler { public Object invoke( Object proxy, final Method method, Object[] args ) throws Throwable { Delegate delegate = null ; try { delegate = StubAdapter.getDelegate( stub ) ; } catch (SystemException ex) { throw Util.getInstance().mapSystemExceptio...
### Question: JNDIStateFactoryImpl implements StateFactory { public Object getStateToBind(Object orig, Name name, Context ctx, Hashtable<?,?> env) throws NamingException { if (orig instanceof org.omg.CORBA.Object) { return orig; } if (!(orig instanceof Remote)) { return null; } ORB orb = getORB( ctx ) ; if (orb == null...
### Question: SocketChannelReader { public ByteBuffer read(SocketChannel channel, ByteBuffer previouslyReadData, int minNeeded) throws IOException { ByteBuffer byteBuffer = prepareToAppendTo(previouslyReadData); int numBytesRead = channel.read(byteBuffer); if (numBytesRead < 0) { throw new EOFException("End of input de...
### Question: SelectorImpl extends Thread implements com.sun.corba.ee.spi.transport.Selector { @Transport public void registerForEvent(EventHandler eventHandler) { if (isClosed()) { closedEventHandler(); return; } if (eventHandler.shouldUseSelectThreadToWait()) { synchronized (deferredRegistrations) { d...
### Question: SelectorImpl extends Thread implements com.sun.corba.ee.spi.transport.Selector { void runSelectionLoopOnce() throws IOException { beginSelect(); int n = 0; handleDeferredRegistrations(); enableInterestOps(); try { n = selector.select(timeout); } catch (IOException e) { display( "Exception ...
### Question: ConnectionImpl extends EventHandlerBase implements Connection, Work { public SocketChannel getSocketChannel() { return socketChannel; } ConnectionImpl(ORB orb); protected ConnectionImpl(ORB orb, boolean useSelectThreadToWait, boolean useWorkerThre...
### Question: IIOPProfileImpl extends IdentifiableBase implements IIOPProfile { @IsLocal public synchronized boolean isLocal() { if (!checkedIsLocal) { checkedIsLocal = true ; if (isForeignObject()) return false; final int port = proftemp.getPrimaryAddress().getPort(); final String host = proftemp.getPrimaryAddress().g...
### Question: AnyImpl extends Any { public TypeCode type() { return typeCode; } AnyImpl(ORB orb); AnyImpl(ORB orb, Any obj); TypeCode type(); void type(TypeCode tc); @DynamicType boolean equal(Any otherAny); org.omg.CORBA.portable.OutputStream create_output_stream(); @DynamicType org.omg.CORBA.portable.InputStream cre...
### Question: AnyImpl extends Any { public byte extract_octet() { checkExtractBadOperation( TCKind._tk_octet ) ; return (byte)value; } AnyImpl(ORB orb); AnyImpl(ORB orb, Any obj); TypeCode type(); void type(TypeCode tc); @DynamicType boolean equal(Any otherAny); org.omg.CORBA.portable.OutputStream create_output_stream...
### Question: PresentationDefaults { synchronized static PresentationManager.StubFactoryFactory getDynamicStubFactoryFactory() { if (dynamicImpl == null) dynamicImpl = new StubFactoryFactoryCodegenImpl(); return dynamicImpl ; } private PresentationDefaults(); synchronized static PresentationManager.StubFactoryFactory ...
### Question: PresentationDefaults { public synchronized static PresentationManager.StubFactoryFactory getStaticStubFactoryFactory() { if (staticImpl == null) staticImpl = new StubFactoryFactoryStaticImpl(); return staticImpl; } private PresentationDefaults(); synchronized static PresentationManager.StubFactoryFactory...
### Question: PresentationDefaults { public static PresentationManagerImpl makeOrbPresentationManager() { final boolean useDynamicStub = getBooleanPropertyValue( ORBConstants.USE_DYNAMIC_STUB_PROPERTY, inAppServer() ) ; final boolean debug = getBooleanPropertyValue( ORBConstants.DEBUG_DYNAMIC_STUB, false ) ; final Pres...
### Question: Util { public static String getVersion () { return getVersion (DEFAULT_MESSAGE_RESOURCE); } static String getVersion(); static boolean isAttribute(String name, Hashtable symbolTable); static boolean isConst(String name, Hashtable symbolTable); static boolean isEnum(String name, Hashtable symbolTable); st...
### Question: Util { public static String getMessage (String key) { if (messages == null) readMessages (); String message = messages.getProperty (key); if (message == null) message = getDefaultMessage (key); return message; } static String getVersion(); static boolean isAttribute(String name, Hashtable symbolTable); s...
### Question: AsmClassFactory implements ClassDefinitionFactory { static int getLatestVersion() { try { int latest = 0; for (Field field : Opcodes.class.getDeclaredFields()) { if (field.getName().startsWith("ASM") && field.getType().equals(int.class)) { latest = Math.max(latest, field.getInt(Opcodes.class)); } } return...
### Question: AdhocProject implements Project, FileOwnerQueryImplementation, ProjectConfiguration, ProjectActionPerformer, ActionProvider, LogicalViewProvider { @Override public FileObject getProjectDirectory() { return dir; } AdhocProject(FileObject dir, ProjectState state); @Override FileObject getPro...
### Question: AdhocProject implements Project, FileOwnerQueryImplementation, ProjectConfiguration, ProjectActionPerformer, ActionProvider, LogicalViewProvider { @Override public Lookup getLookup() { return Lookups.fixed(this, aux, encodingQuery, ops, info, customizer); } AdhocProject(FileObject dir, Pro...
### Question: AdhocProject implements Project, FileOwnerQueryImplementation, ProjectConfiguration, ProjectActionPerformer, ActionProvider, LogicalViewProvider { @Override public String getDisplayName() { return info.getDisplayName(); } AdhocProject(FileObject dir, ProjectState state); @Override FileObje...
### Question: AdhocProject implements Project, FileOwnerQueryImplementation, ProjectConfiguration, ProjectActionPerformer, ActionProvider, LogicalViewProvider { public Charset getEncoding() { try { Preferences p = preferences(false); if (p != null) { String name = p.get("charset", "UTF-8"); return Chars...
### Question: AdhocProject implements Project, FileOwnerQueryImplementation, ProjectConfiguration, ProjectActionPerformer, ActionProvider, LogicalViewProvider { public List<Favorite> favorites() { List<Favorite> favorites = new ArrayList<>(); try { Preferences forProject = preferences(false); if (forPro...
### Question: AdhocProject implements Project, FileOwnerQueryImplementation, ProjectConfiguration, ProjectActionPerformer, ActionProvider, LogicalViewProvider { @Override public Node findPath(Node node, Object o) { AdhocProjectNode view = logicalView == null ? null : logicalView.get(); if (view != null)...
### Question: UserController { @GetMapping("/{userId}") public UserDto getUser(@PathVariable long userId) throws ApplicationException { User user = userService.getUser(userId); return userMapper.toUserDto(user); } UserController(UserMapper userMapper, UserService userService); @GetMapping("/{userId}") UserDto getUser(@...
### Question: IdentityGenerator { public static long generate() { return generate(DEFAULT_SHARD_ID); } private IdentityGenerator(); static Instant extractInstant(long id); static byte extractShardId(long id); static long generate(); static long generate(byte shardId); static final byte DEFAULT_SHARD_ID; static final I...
### Question: IdentityGenerator { static long doGenerate(byte shardId, long time, int serial) { return (shardId & 0x7fL) << 56 | (time & 0xffffffffffL) << 16 | (serial & 0xffff); } private IdentityGenerator(); static Instant extractInstant(long id); static byte extractShardId(long id); static long generate(); static l...
### Question: IdentityGenerator { public static byte extractShardId(long id) { return (byte) ((id >>> 56) & 0x7fL); } private IdentityGenerator(); static Instant extractInstant(long id); static byte extractShardId(long id); static long generate(); static long generate(byte shardId); static final byte DEFAULT_SHARD_ID;...
### Question: IdentityGenerator { public static Instant extractInstant(long id) { long time = (id & 0xffffffffff0000L) >>> 16; return EPOCH.plusMillis(time); } private IdentityGenerator(); static Instant extractInstant(long id); static byte extractShardId(long id); static long generate(); static long generate(byte sha...
### Question: SceneStack implements Iterable<Scene> { boolean isEmpty() { return stack.isEmpty(); } SceneStack(@NonNull Callback callback); @Override Iterator<Scene> iterator(); }### Answer: @Test public void testIsEmpty() { assertTrue(stack.isEmpty()); stack.push(new TestScene()); assertFalse(stack.isEmpty()); stack....
### Question: SceneStack implements Iterable<Scene> { int size() { return stack.size(); } SceneStack(@NonNull Callback callback); @Override Iterator<Scene> iterator(); }### Answer: @Test public void testSize() { Scene scene1 = new TestScene(); Scene scene2 = new TestScene(); Scene scene3 = new TestScene(); assertEqual...
### Question: SceneStack implements Iterable<Scene> { @Nullable Scene peek() { return stack.peekFirst(); } SceneStack(@NonNull Callback callback); @Override Iterator<Scene> iterator(); }### Answer: @Test public void testPeek() { Scene scene1 = new TestScene(); Scene scene2 = new TestScene(); Scene scene3 = new TestSce...
### Question: SceneStack implements Iterable<Scene> { @Nullable Scene tail() { return stack.peekLast(); } SceneStack(@NonNull Callback callback); @Override Iterator<Scene> iterator(); }### Answer: @Test public void testTail() { Scene scene1 = new TestScene(); Scene scene2 = new TestScene(); Scene scene3 = new TestScen...
### Question: Stage implements Iterable<Scene> { @Nullable public Scene getTopScene() { return stack.peek(); } Stage(Director director); void popTopScene(); void pushScene(@NonNull Scene scene); void replaceTopScene(@NonNull Scene scene); void setRootScene(@NonNull Scene scene); boolean hasCurtainRunning(); void comple...
### Question: Stage implements Iterable<Scene> { @Nullable public Scene getRootScene() { return stack.tail(); } Stage(Director director); void popTopScene(); void pushScene(@NonNull Scene scene); void replaceTopScene(@NonNull Scene scene); void setRootScene(@NonNull Scene scene); boolean hasCurtainRunning(); void compl...
### Question: Stage implements Iterable<Scene> { public int getSceneCount() { return stack.size(); } Stage(Director director); void popTopScene(); void pushScene(@NonNull Scene scene); void replaceTopScene(@NonNull Scene scene); void setRootScene(@NonNull Scene scene); boolean hasCurtainRunning(); void completeRunningC...
### Question: Scene { public void recreateView() { if (view == null) { return; } boolean resumed = false; boolean started = false; int index = -1; if (lifecycleState.isResumed()) { resumed = true; pause(); } if (lifecycleState.isStarted()) { started = true; stop(); } if (lifecycleState.isViewAttached()) { index = stage...
### Question: Director implements Iterable<Stage> { @Nullable public Scene findSceneById(int sceneId) { for(int i = 0, n = stageMap.size(); i < n; i++) { Stage stage = stageMap.valueAt(i); Scene result = stage.findSceneById(sceneId); if (result != null) { return result; } } return null; } Director(); @NonNull static Di...
### Question: Director implements Iterable<Stage> { @NonNull public Stage direct(@NonNull ViewGroup container) { return direct(container, container.getId()); } Director(); @NonNull static Director hire(@NonNull Activity activity, @Nullable Bundle savedInstanceState); boolean contains(int id); @Nullable Stage get(int id...
### Question: RunJhsCliParser implements CliParser<RunJhsCommand> { @Override public RunJhsCommand parse(String[] args) { DefaultParser parser = new DefaultParser(); CommandLine cmdLine; cmdLine = CliHelper.tryParse(parser, options, args); return RunJhsCommand.builder() .clientId(cmdLine.getOptionValue(CliConsts.CLIENT...
### Question: DumpHistoryCliParser implements CliParser<DumpHistoryCommand> { @Override public DumpHistoryCommand parse(String[] args) { DefaultParser parser = new DefaultParser(); CommandLine cmdLine; cmdLine = CliHelper.tryParse(parser, options, args); return DumpHistoryCommand.builder() .clientId(cmdLine.getOptionVa...
### Question: HistoryLogUtils { public static Configuration generateHadoopConfig( String clientId, String username, String bucket) { Configuration cfg = new Configuration(false); cfg.addResource(HISTORY_LOG_CONFIG_NAME); cfg.reloadConfiguration(); cfg.set(SPYDRA_HISTORY_CLIENT_ID_PROPERTY, clientId); cfg.set(SPYDRA_HIS...
### Question: HistoryLogUtils { public static Optional<String> findHistoryFilePath( FileSystem fs, String historyDirPrefix, ApplicationId applicationId) throws IOException, URISyntaxException { Path jhistPathPattern = new Path(historyDirPrefix); return findHistoryFilePath( new RemoteIteratorAdaptor<>(fs.listFiles(jhist...
### Question: OnPremiseExecutor implements Executor { @VisibleForTesting List<String> getCommand(SpydraArgument arguments) { addBaseCommand(); if (arguments.getSubmit().getOptions().containsKey(OPTION_JAR)) { addArgument(arguments.getSubmit().getOptions().get(OPTION_JAR)); } if (arguments.getSubmit().getOptions().conta...
### Question: ClusterPlacement { static ClusterPlacement from(String token) { String[] splits = token.split("-"); if (splits.length != 2) { throw new IllegalArgumentException("Could not parse token: " + token); } try { return new ClusterPlacementBuilder() .clusterNumber(Integer.valueOf(splits[0])) .clusterGeneration(Lo...
### Question: ClusterPlacement { String token() { return String.format("%s-%s", clusterNumber(), clusterGeneration()); } Optional<Cluster> findIn(List<Cluster> clusters); }### Answer: @Test public void testToken() { final ClusterPlacement clusterPlacement = new ClusterPlacementBuilder().clusterNumber(10).clusterGener...
### Question: ClusterPlacement { static List<Cluster> filterClusters( List<Cluster> clusters, List<ClusterPlacement> allPlacements) { Set<String> clusterPlacements = allPlacements.stream() .map(ClusterPlacement::token) .collect(toSet()); return clusters.stream() .filter(cluster -> clusterPlacements.contains(placement(c...
### Question: ClusterPlacement { public Optional<Cluster> findIn(List<Cluster> clusters) { return clusters.stream() .filter(cluster -> this.equals(placement(cluster))) .findFirst(); } Optional<Cluster> findIn(List<Cluster> clusters); }### Answer: @Test public void testFindIn() { final ClusterPlacement missingPlacemen...
### Question: DynamicSubmitter extends Submitter { public boolean releaseCluster(SpydraArgument arguments, DataprocApi dataprocApi) throws IOException { try { waitForHistoryToBeMoved(arguments); } finally { return dataprocApi.deleteCluster(arguments); } } DynamicSubmitter(); DynamicSubmitter(DataprocApi dataprocApi, G...
### Question: SubmissionCliParser implements CliParser<SpydraArgument> { public SpydraArgument parse(String[] args) throws IOException { DefaultParser parser = new DefaultParser(); CommandLine cmdLine; cmdLine = CliHelper.tryParse(parser, options, args); SpydraArgument spydraArgument = new SpydraArgument(); if (cmdLine...
### Question: DumpLogsCliParser implements CliParser<DumpLogsCommand> { @Override public DumpLogsCommand parse(String[] args) { DefaultParser parser = new DefaultParser(); CommandLine cmdLine; cmdLine = CliHelper.tryParse(parser, options, args); return DumpLogsCommand.builder() .clientId(cmdLine.getOptionValue(CliConst...
### Question: BookController { @DeleteMapping("/{id}") public void delete(@PathVariable Long id) { System.out.println(id); bookService.delete(id); } @GetMapping // @JsonView(BookListView.class) @ApiOperation("查询图书信息") Page<BookInfo> query(BookCondition condition, Pageable pageable); @GetMapping("/{id}") // @JsonView(B...
### Question: Packer implements Writable, MessageFormatter { @Override public void writeBinary(byte[] binary, int offset, int length) { writeBinaryHeader(length); buffer.put(binary, offset, length); } Packer(Codec codec, ByteBufferConsumer sink, ByteBuffer buffer, boolean manualReset); Packer(Codec codec, ByteBufferCo...
### Question: OpenJdkOngoingRecording implements OngoingRecording { @Override public OpenJdkRecordingData snapshot(final Instant start, final Instant end) { if (recording.getState() != RecordingState.RUNNING) { throw new IllegalStateException("Cannot snapshot recording that is not running"); } final Recording snapshot ...
### Question: OpenJdkOngoingRecording implements OngoingRecording { @Override public void close() { recording.close(); } OpenJdkOngoingRecording(final Recording recording); @Override OpenJdkRecordingData stop(); @Override OpenJdkRecordingData snapshot(final Instant start, final Instant end); @Override void close(); }#...
### Question: OpenJdkController implements Controller { @Override public OpenJdkOngoingRecording createRecording(final String recordingName) { final Recording recording = new Recording(); recording.setName(recordingName); recording.setSettings(recordingSettings); recording.setMaxSize(RECORDING_MAX_SIZE); recording.setM...
### Question: OpenJdkRecordingData implements RecordingData { @Override public InputStream getStream() throws IOException { return recording.getStream(start, end); } OpenJdkRecordingData(final Recording recording); OpenJdkRecordingData(final Recording recording, final Instant start, final Instant end); @Override Inpu...
### Question: OpenJdkRecordingData implements RecordingData { @Override public void release() { recording.close(); } OpenJdkRecordingData(final Recording recording); OpenJdkRecordingData(final Recording recording, final Instant start, final Instant end); @Override InputStream getStream(); @Override void release(); @O...
### Question: OpenJdkRecordingData implements RecordingData { @Override public String getName() { return recording.getName(); } OpenJdkRecordingData(final Recording recording); OpenJdkRecordingData(final Recording recording, final Instant start, final Instant end); @Override InputStream getStream(); @Override void re...
### Question: OpenJdkRecordingData implements RecordingData { @Override public String toString() { return "OpenJdkRecording: " + getName(); } OpenJdkRecordingData(final Recording recording); OpenJdkRecordingData(final Recording recording, final Instant start, final Instant end); @Override InputStream getStream(); @Ov...
### Question: OpenJdkRecordingData implements RecordingData { @Override public Instant getStart() { return start; } OpenJdkRecordingData(final Recording recording); OpenJdkRecordingData(final Recording recording, final Instant start, final Instant end); @Override InputStream getStream(); @Override void release(); @Ov...
### Question: OpenJdkRecordingData implements RecordingData { @Override public Instant getEnd() { return end; } OpenJdkRecordingData(final Recording recording); OpenJdkRecordingData(final Recording recording, final Instant start, final Instant end); @Override InputStream getStream(); @Override void release(); @Overri...
### Question: Packer implements Writable, MessageFormatter { @Override public void writeNull() { buffer.put(NULL); } Packer(Codec codec, ByteBufferConsumer sink, ByteBuffer buffer, boolean manualReset); Packer(Codec codec, ByteBufferConsumer sink, ByteBuffer buffer); Packer(ByteBufferConsumer sink, ByteBuffer buffer)...
### Question: OpenJdkRecordingData implements RecordingData { Recording getRecording() { return recording; } OpenJdkRecordingData(final Recording recording); OpenJdkRecordingData(final Recording recording, final Instant start, final Instant end); @Override InputStream getStream(); @Override void release(); @Override ...
### Question: DeadlockEventFactory { final List<? extends Event> collectEvents() { if (!isDeadlockEventEnabled()) { return Collections.emptyList(); } long[] locked = threadMXBean.findDeadlockedThreads(); if (locked == null) { return Collections.emptyList(); } long id = deadlockCounter.getAndIncrement(); List<Event> eve...
### Question: JfpUtils { public static Map<String, String> readNamedJfpResource( final String name, final String overridesFile) throws IOException { final Map<String, String> result; try (final InputStream stream = getNamedResource(name)) { result = readJfpFile(stream); } if (overridesFile != null) { try (final InputSt...
### Question: StreamUtils { public static <T> T readStream( final InputStream is, final int expectedSize, final BytesConsumer<T> consumer) throws IOException { final byte[] bytes = new byte[expectedSize]; int remaining = expectedSize; while (remaining > 0) { final int offset = expectedSize - remaining; final int read =...
### Question: StreamUtils { public static <T> T gzipStream( InputStream is, final int expectedSize, final BytesConsumer<T> consumer) throws IOException { is = ensureMarkSupported(is); if (isCompressed(is)) { return readStream(is, expectedSize, consumer); } else { final FastByteArrayOutputStream baos = new FastByteArray...
### Question: Packer implements Writable, MessageFormatter { @Override public void writeBoolean(boolean value) { buffer.put(value ? TRUE : FALSE); } Packer(Codec codec, ByteBufferConsumer sink, ByteBuffer buffer, boolean manualReset); Packer(Codec codec, ByteBufferConsumer sink, ByteBuffer buffer); Packer(ByteBufferC...
### Question: StreamUtils { public static <T> T lz4Stream( InputStream is, final int expectedSize, final BytesConsumer<T> consumer) throws IOException { is = ensureMarkSupported(is); if (isCompressed(is)) { return readStream(is, expectedSize, consumer); } else { final FastByteArrayOutputStream baos = new FastByteArrayO...
### Question: ConstantPool { public T get(int index) { return index < 0 ? null : reverseIndexMap.get(index); } ConstantPool(); ConstantPool(int startingIndex); T get(int index); int getOrInsert(T constant); void insert(int ptr, T constant); int size(); }### Answer: @Test void getByIndexEmpty() { assertNull(instance....
### Question: ProfileUploader { OkHttpClient getClient() { return client; } ProfileUploader(final Config config); ProfileUploader( final Config config, final RatelimitedLogger ratelimitedLogger, final String containerId); void upload(final RecordingType type, final RecordingData data); void shutdown(); }### An...
### Question: ConstantPool { public void insert(int ptr, T constant) { if (constant == null) { if (ptr != -1) { throw new IllegalArgumentException(); } return; } indexMap.put(constant, ptr); reverseIndexMap.put(ptr, constant); offset = Math.max(offset, ptr + 1); } ConstantPool(); ConstantPool(int startingIndex); T ge...
### Question: ProfileUploader { public void shutdown() { okHttpExecutorService.shutdownNow(); try { okHttpExecutorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.warn("Wait for executor shutdown interrupted"); } client.connectionPool().evictAll(); } ProfileU...
### Question: ProfilingThreadFactory implements ThreadFactory { @Override public Thread newThread(final Runnable r) { final Thread t = new Thread(THREAD_GROUP, r, name); t.setDaemon(true); return t; } ProfilingThreadFactory(final String name); @Override Thread newThread(final Runnable r); }### Answer: @Test public voi...