auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public JedisClusterInfoCache(final GenericObjectPoolConfig poolConfig, int timeout) { this(poolConfig, timeout, timeout, null, null, false, null, null, null, null); }

Target:
public JedisClusterInfoCache(final GenericObjectPoolConfig poolConfig, int timeout) { this(poolConfig, timeout, timeout, null, null); }
Source:
public void useWithoutConnecting() { jedis.auth("foobared"); Jedis jedis = new Jedis("localhost"); jedis.dbSize(); }

Target:
public void useWithoutConnecting() { Jedis jedis = new Jedis("localhost"); jedis.auth("foobared"); jedis.dbSize(); }
Source:
int count() { if (params.containsKey(COUNT)) { return params.get(COUNT).getInt(); } else { return SCAN_COUNT_DEFAULT.getInt(); } }

Target:
Integer count() { if (params.containsKey(COUNT)) { return params.get(COUNT).getInt(); } else { return null; } }
Source:
public static boolean isClusterCompliantMatchPattern(String matchPattern) { String tag = extractHashTag(matchPattern, true, true); if (tag != null && !tag.isEmpty() && matchPattern.startsWith(tag)) { return matchPattern.substring(tag.length()).equals("*"); } else { return false; } }

Target:
public static boolean isClusterCompliantMatchPattern(String matchPattern) { String tag = extractHashTag(matchPattern, false); return tag != null && !tag.isEmpty(); }
Source:
int count() { if (params.containsKey(COUNT)) { return params.get(COUNT).getInt(); } else { return 0; } }

Target:
Integer count() { if (params.containsKey(COUNT)) { return params.get(COUNT).getInt(); } else { return null; } }
Source:
public void zrevrangeByScoreWithScores(final byte[] key, final double max, final double min) { sendCommand(ZREVRANGEBYSCORE, key, toByteArray(min), toByteArray(max), WITHSCORES.raw); }

Target:
public void zrevrangeByScoreWithScores(final byte[] key, final double max, final double min) { sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min), WITHSCORES.raw); }
Source:
public void zrevrangeByScore(final byte[] key, final double max, final double min, final int offset, int count) { sendCommand(ZREVRANGEBYSCORE, key, toByteArray(min), toByteArray(max), LIMIT.raw, toByteArray(offset), toByteArray(count)); }

Target:
public void zrevrangeByScore(final byte[] key, final double max, final double min, final int offset, int count) { sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min), LIMIT.raw, toByteArray(offset), toByteArray(count)); }
Source:
public void zrevrangeByScore(final byte[] key, final double max, final double min) { sendCommand(ZREVRANGEBYSCORE, key, toByteArray(min), toByteArray(max)); }

Target:
public void zrevrangeByScore(final byte[] key, final double max, final double min) { sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min)); }
Source:
public Long del(final String key) { return new JedisClusterCommand<Long>(connectionHandler, timeout, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.del(key); } }.run(key); }

Target:
public Long del(final String key) { return new JedisClusterCommand<Long>(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.del(key); } }.run(key); }
Source:
public static void removeSlots() throws InterruptedException { String[] nodes = node1.clusterNodes().split("\n"); String node1Id = nodes[0].split(" ")[0]; node1.clusterReset(Reset.SOFT); node2.clusterReset(Reset.SOFT); }

Target:
public static void removeSlots() throws InterruptedException { node1.clusterReset(Reset.SOFT); node2.clusterReset(Reset.SOFT); }
Source:
public String set(final byte[] key, final byte[] value) { return new JedisClusterCommand<String>(connectionHandler, timeout, maxRedirections) { @Override public String execute(Jedis connection) { return connection.set(key, value); } }.runBinary(key); }

Target:
public String set(final byte[] key, final byte[] value) { return new JedisClusterCommand<String>(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.set(key, value); } }.runBinary(key); }
Source:
public byte[] echo(final byte[] arg) { return new JedisClusterCommand<byte[]>(connectionHandler, timeout, maxRedirections) { @Override public byte[] execute(Jedis connection) { return connection.echo(arg); } }.runBinary(null); }

Target:
public byte[] echo(final byte[] arg) { // note that it'll be run from arbitary node return new JedisClusterCommand<byte[]>(connectionHandler, maxRedirections) { @Override public byte[] execute(Jedis connection) { return connection.echo(arg); } }.runBinary(arg); }
Source:
public List<byte[]> blpop(final byte[] arg) { return new JedisClusterCommand<List<byte[]>>(connectionHandler, timeout, maxRedirections) { @Override public List<byte[]> execute(Jedis connection) { return connection.blpop(arg); } }.runBinary(null); }

Target:
public List<byte[]> blpop(final byte[] arg) { return new JedisClusterCommand<List<byte[]>>(connectionHandler, timeout, maxRedirections) { @Override public List<byte[]> execute(Jedis connection) { return connection.blpop(arg); } }.runBinary(arg); }
Source:
public Long move(final byte[] key, final int dbIndex) { return new JedisClusterCommand<Long>(connectionHandler, timeout, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.move(key, dbIndex); } }.runBinary(key); }

Target:
public Long move(final byte[] key, final int dbIndex) { return new JedisClusterCommand<Long>(connectionHandler, timeout, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.move(key, dbIndex); } }.runBinary(null); }
Source:
public Object eval(final String script, final String key) { return new JedisClusterCommand<Object>(connectionHandler, timeout, maxRedirections) { @Override public Object execute(Jedis connection) { return connection.eval(script); } }.run(1, key); }

Target:
public Object eval(final String script, final String key) { return new JedisClusterCommand<Object>(connectionHandler, timeout, maxRedirections) { @Override public Object execute(Jedis connection) { return connection.eval(script); } }.run(key); }
Source:
public List<Boolean> scriptExists(final String key, final String... sha1) { return new JedisClusterCommand<List<Boolean>>(connectionHandler, timeout, maxRedirections) { @Override public List<Boolean> execute(Jedis connection) { return connection.scriptExists(sha1); } }.run(1, key); }

Target:
public List<Boolean> scriptExists(final String key, final String... sha1) { return new JedisClusterCommand<List<Boolean>>(connectionHandler, timeout, maxRedirections) { @Override public List<Boolean> execute(Jedis connection) { return connection.scriptExists(sha1); } }.run(key); }
Source:
public String scriptLoad(final String script, final String key) { return new JedisClusterCommand<String>(connectionHandler, timeout, maxRedirections) { @Override public String execute(Jedis connection) { return connection.scriptLoad(script); } }.run(1, key); }

Target:
public String scriptLoad(final String script, final String key) { return new JedisClusterCommand<String>(connectionHandler, timeout, maxRedirections) { @Override public String execute(Jedis connection) { return connection.scriptLoad(script); } }.run(key); }
Source:
public ScanResult(byte[] cursor, List<T> results) { this.cursor = SafeEncoder.encode(cursor); this.results = results; }

Target:
public ScanResult(byte[] cursor, List<T> results) { this.cursor = cursor; this.results = results; }
Source:
private void initializeSlotsCache(Set<HostAndPort> nodes) { for (HostAndPort hostAndPort : nodes) { JedisPool jp = new JedisPool(hostAndPort.getHost(), hostAndPort.getPort()); this.nodes.put(hostAndPort.getHost() + hostAndPort.getPort(), jp); Jedis jedis = jp.getResource(); discoverClusterNodesAndSlots(jedis); jp.returnResource(jedis); } }

Target:
private void initializeSlotsCache(Set<HostAndPort> nodes) { for (HostAndPort hostAndPort : nodes) { JedisPool jp = new JedisPool(hostAndPort.getHost(), hostAndPort.getPort()); this.nodes.put(hostAndPort.getHost() + hostAndPort.getPort(), jp); Jedis jedis = jp.getResource(); try { discoverClusterNodesAndSlots(jedis); } finally { jp.returnResource(jedis); } } }
Source:
protected String detect( InputStream inputStream, Metadata metadata ) { try { // we never care about the stream here, but close it anyway IoUtil.closeQuietly(inputStream); MediaType detectedMimeType = detector.detect(null, metadata); if (logger.isTraceEnabled()) { logger.trace("MIME type for '" + metadata.get(Metadata.RESOURCE_NAME_KEY) + "' ==> " + detectedMimeType); } return detectedMimeType.toString(); } catch (Exception e) { logger.debug(e, "Unable to extract mime-type"); return null; } }

Target:
protected String detect( InputStream inputStream, Metadata metadata ) { try { // we never care about the stream here, but close it anyway MediaType detectedMimeType = detector.detect(null, metadata); if (logger.isTraceEnabled()) { logger.trace("MIME type for '" + metadata.get(Metadata.RESOURCE_NAME_KEY) + "' ==> " + detectedMimeType); } return detectedMimeType.toString(); } catch (Exception e) { logger.debug(e, "Unable to extract mime-type"); return null; } finally { IoUtil.closeQuietly(inputStream); } }
Source:
public boolean hasNext() { if (last != null) return true; // 'hasNext()' has been called multiple times before 'next()' while (super.hasNext()) { last = super.next(); if (last.getName().equals(name)) { return true; } else { last = null; } } return false; }

Target:
public boolean hasNext() { if (last != null) return true; // 'hasNext()' has been called multiple times before 'next()' while (super.hasNext()) { last = super.next(); if (last.getName().equals(name)) return true; last = null; } return false; }
Source:
public void addEventListener( EventListener listener, int eventTypes, String absPath, boolean isDeep, String[] uuid, String[] nodeTypeName, boolean noLocal ) throws RepositoryException { CheckArg.isNotNull(listener, "listener"); checkSession(); // make sure session is still active // create wrapper and register JcrListenerAdapter adapter = new JcrListenerAdapter(listener, eventTypes, absPath, isDeep, uuid, nodeTypeName, noLocal); this.repositoryObservable.register(adapter); this.listeners.add(adapter); }

Target:
public void addEventListener( EventListener listener, int eventTypes, String absPath, boolean isDeep, String[] uuid, String[] nodeTypeName, boolean noLocal ) throws RepositoryException { CheckArg.isNotNull(listener, "listener"); checkSession(); // make sure session is still active // create wrapper and register JcrListenerAdapter adapter = new JcrListenerAdapter(listener, eventTypes, absPath, isDeep, uuid, nodeTypeName, noLocal); if (this.repositoryObservable.register(adapter)) { this.listeners.add(adapter); } }
Source:
public Iterator<ChildReference> iterator( Name name, Context context ) { if (context != null && context.changes() != null) { //we only want the context-sensitive behavior if there are changes. Otherwise we've already precomputed the SNS index return super.iterator(name, context); } else { return iterator(name); } }

Target:
public Iterator<ChildReference> iterator( Name name, Context context ) { if (context != null && context.changes() != null) { //we only want the context-sensitive behavior if there are changes. Otherwise we've already precomputed the SNS index return super.iterator(name, context); } return iterator(name); }
Source:
public void close() { if (this.runThread.compareAndSet(true, false)) { try { cursor.signalConsumers(); this.stopLatch.await(); // System.out.println("Ring buffer garbage collection thread has terminated"); } catch (InterruptedException e) { // do nothing ... } } }

Target:
public void close() { if (this.runThread.compareAndSet(true, false)) { try { this.stopLatch.await(); } catch (InterruptedException e) { // do nothing ... } } }
Source:
private void incrementEventQueueStatistic( ChangeSet changeSet ) { changesLock.lock(); try { // whenever a change set is received from the bus, increment the que size if (repositoryStatistics != null) { repositoryStatistics.increment(ValueMetric.EVENT_QUEUE_SIZE); } if (!this.changesReceivedAndDispatched.containsKey(changeSet.hashCode())) { // none of the adapters have processed this change set yet, register it changesReceivedAndDispatched.put(changeSet.hashCode(), new AtomicInteger(listeners.size())); } } finally { changesLock.unlock(); } }

Target:
private void incrementEventQueueStatistic( ChangeSet changeSet ) { // whenever a change set is received from the bus, increment the que size if (repositoryStatistics != null) { repositoryStatistics.increment(ValueMetric.EVENT_QUEUE_SIZE); } changesLock.lock(); try { if (!this.changesReceivedAndDispatched.containsKey(changeSet.hashCode())) { // none of the adapters have processed this change set yet, register it changesReceivedAndDispatched.put(changeSet.hashCode(), new AtomicInteger(listeners.size())); } } finally { changesLock.unlock(); } }
Source:
public AccessControlManagerImpl(JcrSession session) { this.session = session; this.privileges = new Privileges(session); this.defaultACL = JcrAccessControlList.defaultAcl(this); }

Target:
protected AccessControlManagerImpl(JcrSession session) { this.session = session; this.privileges = new Privileges(session); this.defaultACL = JcrAccessControlList.defaultAcl(this); }
Source:
protected InternalSecurityContext( String username ) { this.username = username; //given user is only known principal for this context principals.add(SimplePrincipal.newInstance(username)); }

Target:
protected InternalSecurityContext( String username ) { this.username = username; }
Source:
protected void parsePackagesSheet( Repository<Entity> repo, IntermediateParseResults intermediateResults) { if (repo == null) return; // Collect packages int rowIndex = 1; for (Entity packageEntity : resolvePackages(repo)) { rowIndex++; parseSinglePackage(intermediateResults, rowIndex, packageEntity); } }

Target:
private void parsePackagesSheet( Repository<Entity> repo, IntermediateParseResults intermediateResults) { if (repo == null) return; // Collect packages int rowIndex = 1; for (Entity packageEntity : resolvePackages(repo)) { rowIndex++; parseSinglePackage(intermediateResults, rowIndex, packageEntity); } }
Source:
public static CopyState create(@Nullable Package targetPackage, Progress progress) { return new AutoValue_CopyState( targetPackage, progress, new ArrayList<>(), new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>()); }

Target:
public static CopyState create(@Nullable Package targetPackage, Progress progress) { return new CopyState(targetPackage, progress); }
Source:
public void testHasSheetTrue() { Sheet sheet = mock(Sheet.class); when(workbook.getSheet("test")).thenReturn(sheet); assertEquals(true, excelWriter.hasSheet("test")); }

Target:
public void testHasSheetTrue() { Sheet sheet = mock(Sheet.class); when(workbook.getSheet("test")).thenReturn(sheet); assertTrue(excelWriter.hasSheet("test")); }
Source:
public void notifyVideoEnd() // Must match Javascript interface method of VideoEnabledWebChromeClient { Log.d("___", "GOT IT"); // This code is not executed in the UI thread, so we must force that to happen new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (videoEnabledWebChromeClient != null) { videoEnabledWebChromeClient.onHideCustomView(); } } }); }

Target:
public void notifyVideoEnd() // Must match Javascript interface method of VideoEnabledWebChromeClient { // This code is not executed in the UI thread, so we must force that to happen new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (videoEnabledWebChromeClient != null) { videoEnabledWebChromeClient.onHideCustomView(); } } }); }
Source:
private String parseCodeName() { if (this.major == 10) { MACOS_VERSIONS_PROPERTIES = "macos.versions.properties"; Properties verProps = FileUtil.readPropertiesFromFilename(MACOS_VERSIONS_PROPERTIES); String version_number = this.major + "." + this.minor; String version_name = verProps.getProperty(version_number); return version_name; } LOG.warn("Unable to parse version {}.{} to a codename.", this.major, this.minor); return ""; }

Target:
private String parseCodeName() { if (this.major == 10) { Properties verProps = FileUtil.readPropertiesFromFilename(MACOS_VERSIONS_PROPERTIES); return verProps.getProperty(this.major + "." + this.minor); } LOG.warn("Unable to parse version {}.{} to a codename.", this.major, this.minor); return ""; }
Source:
public List<Integer> getTransferAbortedOkStatusCodes(final FileSystemOptions opts) { // See VFS-674, its accompanying PR and https://github.com/apache/commons-vfs/pull/51 as to why 426 and 550 are here @SuppressWarnings("unchecked") List<Integer> statusCodes = (List<Integer>) getParam(opts, TRANSFER_ABORTED_OK_STATUS_CODES); return statusCodes != null ? statusCodes : Arrays.asList(FTPReply.TRANSFER_ABORTED, FTPReply.FILE_UNAVAILABLE); }

Target:
public List<Integer> getTransferAbortedOkStatusCodes(final FileSystemOptions opts) { return (List<Integer>) getParam(opts, TRANSFER_ABORTED_OK_STATUS_CODES); }
Source:
public ElementData render() { ElementData result = new ElementData("Differential privacy"); result.addProperty("Epsilon", epsilon); result.addProperty("Delta", delta); result.addProperty("Uniqueness threshold (k)", getK()); result.addProperty("Sampling probability (beta)", getBeta()); return result; }

Target:
public ElementData render() { ElementData result = new ElementData("Differential privacy"); result.addProperty("Epsilon", epsilon); result.addProperty("Delta", delta); try { result.addProperty("Uniqueness threshold (k)", getK()); result.addProperty("Sampling probability (beta)", getBeta()); } catch (Exception e) { // No harm is done if these properties can not be set } return result; }
Source:
public Image getImage(AttributeType type) { if (type == AttributeType.IDENTIFYING_ATTRIBUTE) { return getManagedImage("bullet_red.png"); } if (type == AttributeType.INSENSITIVE_ATTRIBUTE) { return getManagedImage("bullet_green.png"); } if (type == AttributeType.SENSITIVE_ATTRIBUTE) { return getManagedImage("bullet_purple.png"); } if (type == AttributeType.QUASI_IDENTIFYING_ATTRIBUTE) { return getManagedImage("bullet_yellow.png"); } throw new IllegalArgumentException("Unknown attribute type '" + type +"'"); }

Target:
public Image getImage(AttributeType type) { if (type == AttributeType.IDENTIFYING_ATTRIBUTE) { return getManagedImage("bullet_red.png"); } else if (type == AttributeType.INSENSITIVE_ATTRIBUTE) { return getManagedImage("bullet_green.png"); } else if (type == AttributeType.SENSITIVE_ATTRIBUTE) { return getManagedImage("bullet_purple.png"); } else if (type == AttributeType.QUASI_IDENTIFYING_ATTRIBUTE) { return getManagedImage("bullet_yellow.png"); } else { throw new IllegalArgumentException("Unknown attribute type '" + type + "'"); } }
Source:
public void release(Statement statement) { log.tracev( "Releasing statement [{0}]", statement ); final Set<ResultSet> resultSets = xref.get( statement ); if ( resultSets != null ) { closeAll( resultSets ); xref.remove( statement ); } else if ( log.isDebugEnabled() ) { // Keep this at DEBUG level, rather than warn. Numerous connection pool implementations can return a // proxy/wrapper around the JDBC Statement, causing excessive logging here. See HHH-8210. log.unregisteredStatement(); } close( statement ); if ( lastQuery == statement ) { lastQuery = null; } }

Target:
public void release(Statement statement) { log.tracev( "Releasing statement [{0}]", statement ); // Keep this at DEBUG level, rather than warn. Numerous connection pool implementations can return a // proxy/wrapper around the JDBC Statement, causing excessive logging here. See HHH-8210. if ( log.isDebugEnabled() && !xref.containsKey( statement ) ) { log.unregisteredStatement(); } else { final Set<ResultSet> resultSets = xref.get( statement ); if ( resultSets != null ) { closeAll( resultSets ); } xref.remove( statement ); } close( statement ); if ( lastQuery == statement ) { lastQuery = null; } }
Source:
protected void createLoaders() { final Map loaders = getLoaders(); loaders.put( LockMode.NONE, createEntityLoader( LockMode.NONE ) ); noneLockLoader = createEntityLoader( LockMode.NONE ); readLockLoader = createEntityLoader( LockMode.READ ); // The loaders for the other lock modes are loaded lazily. loaders.put( "merge", new CascadeEntityLoader( this, CascadingActions.MERGE, getFactory() ) ); loaders.put( "refresh", new CascadeEntityLoader( this, CascadingActions.REFRESH, getFactory() ) ); }

Target:
protected void createLoaders() { // We load the entity loaders for the most common lock modes. noneLockLoader = createEntityLoader( LockMode.NONE ); readLockLoader = createEntityLoader( LockMode.READ ); final Map loaders = getLoaders(); // The loaders for the other lock modes are lazily loaded and will later be stored in this map. loaders.put( "merge", new CascadeEntityLoader( this, CascadingActions.MERGE, getFactory() ) ); loaders.put( "refresh", new CascadeEntityLoader( this, CascadingActions.REFRESH, getFactory() ) ); }
Source:
public static String toArrayTypeString(ArrayType type, Context context) { TypeMirror componentMirror = type.getComponentType(); if ( !componentMirror.getAnnotationMirrors().isEmpty() ) { TypeMirror component = type.getComponentType().accept( new SimpleTypeVisitor6<TypeMirror, Void>() { @Override protected TypeMirror defaultAction(TypeMirror e, Void aVoid) { return e; } }, null ); return extractClosestRealTypeAsString( component, context ) + "[]"; } return toTypeString( type ); }

Target:
public static String toArrayTypeString(ArrayType type, Context context) { // When an ArrayType is annotated with an annotation which uses TYPE_USE targets, // we cannot simply take the TypeMirror returned by #getComponentType because it // itself is an AnnotatedType. // // The simplest approach here to get the TypeMirror for both ArrayType use cases // is to use the visitor to retrieve the underlying TypeMirror. TypeMirror component = type.getComponentType().accept( new SimpleTypeVisitor6<TypeMirror, Void>() { @Override protected TypeMirror defaultAction(TypeMirror e, Void aVoid) { return e; } }, null ); return extractClosestRealTypeAsString( component, context ) + "[]"; }
Source:
public void begin() { if ( !session.isOpen() ) { throw new IllegalStateException( "Cannot begin Transaction on closed Session/EntityManager" ); } if ( transactionDriverControl == null ) { transactionDriverControl = transactionCoordinator.getTransactionDriverControl(); } // per-JPA if ( isActive() ) { throw new IllegalStateException( "Transaction already active" ); } if ( LOG.isDebugEnabled() ) { LOG.debug( "begin" ); } this.transactionDriverControl.begin(); }

Target:
public void begin() { if ( !session.isOpen() ) { throw new IllegalStateException( "Cannot begin Transaction on closed Session/EntityManager" ); } if ( transactionDriverControl == null ) { transactionDriverControl = transactionCoordinator.getTransactionDriverControl(); } // per-JPA if ( isActive() ) { throw new IllegalStateException( "Transaction already active" ); } LOG.debug( "begin" ); this.transactionDriverControl.begin(); }
Source:
private static int calculateBinaryShiftCost(State state) { if (state.binaryShiftByteCount > 62) { return 21; // B/S with extended length } else if (state.binaryShiftByteCount > 31) { return 20; // two B/S } else if (state.binaryShiftByteCount > 0) { return 10; // one B/S } else { return 0; } }

Target:
private static int calculateBinaryShiftCost(State state) { if (state.binaryShiftByteCount > 62) { return 21; // B/S with extended length } if (state.binaryShiftByteCount > 31) { return 20; // two B/S } if (state.binaryShiftByteCount > 0) { return 10; // one B/S } return 0; }
Source:
protected static int appendPattern(boolean[] target, int pos, int[] pattern, boolean startColor) { int numAdded = 9; for (int bit : pattern) { target[pos++] = bit != 0; } return numAdded; }

Target:
protected static int appendPattern(boolean[] target, int pos, int[] pattern, boolean startColor) { for (int bit : pattern) { target[pos++] = bit != 0; } return 9; }
Source:
public AbstractSecurityKeySignature(String keyType) { this.keyType = keyType; }

Target:
protected AbstractSecurityKeySignature(String keyType) { this.keyType = keyType; }
Source:
public static String getFileOwner(Path path, LinkOption... options) throws IOException { String owner = null; try { UserPrincipal principal = Files.getOwner(path, options); if (principal != null) { owner = principal.getName(); } } catch (UnsupportedOperationException e) { // ignore } return owner; }

Target:
public static String getFileOwner(Path path, LinkOption... options) throws IOException { try { UserPrincipal principal = Files.getOwner(path, options); return (principal == null) ? null : principal.getName(); } catch (UnsupportedOperationException e) { return null; } }
Source:
public JsonWebToken currentPrincipal() { Objects.requireNonNull(httpServletRequest, "HTTP Servlet Request is required to produce a JSonWebToken principal."); // not very beatiful, but avoids having the MPJWTFilter setting the request or the principal in a thread local // CDI integration already has one - dunno which approach is the best for now final Object tokenAttribute = httpServletRequest.getAttribute(JsonWebToken.class.getName()); if (tokenAttribute != null && Function.class.isInstance(tokenAttribute)) { return (JsonWebToken) Function.class.cast(tokenAttribute).apply(httpServletRequest); } return null; }

Target:
public JsonWebToken currentPrincipal() { Objects.requireNonNull(httpServletRequest, "HTTP Servlet Request is required to produce a JSonWebToken principal."); // not very beautiful, but avoids having the MPJWTFilter setting the request or the principal in a thread local // CDI integration already has one - dunno which approach is the best for now final Object tokenAttribute = httpServletRequest.getAttribute(JsonWebToken.class.getName()); if (Function.class.isInstance(tokenAttribute)) { return (JsonWebToken) Function.class.cast(tokenAttribute).apply(httpServletRequest); } return null; }
Source:
@Provides @Singleton ManagedServer providesServer(WebConfiguration webConfiguration) { return new WebServer(webConfiguration); }

Target:
@Provides @Singleton WebServer providesServer(WebConfiguration webConfiguration) { return new WebServer(webConfiguration); }
Source:
public ClassifierCompositeItemWriterBuilder<T> classifier(Classifier<T, ItemWriter<? super T>> classifier) { Assert.notNull(classifier, "A classifier is required."); this.classifier = classifier; return this; }

Target:
public ClassifierCompositeItemWriterBuilder<T> classifier(Classifier<T, ItemWriter<? super T>> classifier) { this.classifier = classifier; return this; }
Source:
static int getExifRotation(int orientation) { int rotation; switch (orientation) { case ORIENTATION_ROTATE_90: case ORIENTATION_TRANSPOSE: rotation = 90; break; case ORIENTATION_ROTATE_180: case ORIENTATION_FLIP_VERTICAL: rotation = 180; break; case ORIENTATION_ROTATE_270: case ORIENTATION_TRANSVERSE: rotation = 270; break; default: rotation = 0; } return rotation; }

Target:
private static int getExifRotation(int orientation) { int rotation; switch (orientation) { case ORIENTATION_ROTATE_90: case ORIENTATION_TRANSPOSE: rotation = 90; break; case ORIENTATION_ROTATE_180: case ORIENTATION_FLIP_VERTICAL: rotation = 180; break; case ORIENTATION_ROTATE_270: case ORIENTATION_TRANSVERSE: rotation = 270; break; default: rotation = 0; } return rotation; }
Source:
static int getExifTranslation(int orientation) { int translation; switch (orientation) { case ORIENTATION_FLIP_HORIZONTAL: case ORIENTATION_FLIP_VERTICAL: case ORIENTATION_TRANSPOSE: case ORIENTATION_TRANSVERSE: translation = -1; break; default: translation = 1; } return translation; }

Target:
private static int getExifTranslation(int orientation) { int translation; switch (orientation) { case ORIENTATION_FLIP_HORIZONTAL: case ORIENTATION_FLIP_VERTICAL: case ORIENTATION_TRANSPOSE: case ORIENTATION_TRANSVERSE: translation = -1; break; default: translation = 1; } return translation; }
Source:
public void cancelRequest(ImageView view) { // checkMain() is called from cancelExistingRequest() if (view == null) { throw new AssertionError("view cannot be null."); } cancelExistingRequest(view); }

Target:
public void cancelRequest(ImageView view) { // checkMain() is called from cancelExistingRequest() if (view == null) { throw new IllegalArgumentException("view cannot be null."); } cancelExistingRequest(view); }
Source:
@SuppressWarnings("UnusedDeclaration") public void setLoggingEnabled(boolean enabled) { loggingEnabled = enabled; }

Target:
public void setLoggingEnabled(boolean enabled) { loggingEnabled = enabled; }
Source:
public RequestCreator memoryPolicy(MemoryPolicy policy, MemoryPolicy... additional) { if (policy == null) { throw new IllegalArgumentException("Memory policy cannot be null."); } this.memoryPolicy |= policy.index; if (additional != null && additional.length > 0) { for (MemoryPolicy memoryPolicy : additional) { if (memoryPolicy == null) { throw new IllegalArgumentException("Memory policy cannot be null."); } this.memoryPolicy |= memoryPolicy.index; } } return this; }

Target:
public RequestCreator memoryPolicy(MemoryPolicy policy, MemoryPolicy... additional) { if (policy == null) { throw new IllegalArgumentException("Memory policy cannot be null."); } this.memoryPolicy |= policy.index; if (additional == null) { throw new IllegalArgumentException("Memory policy cannot be null."); } if (additional.length > 0) { for (MemoryPolicy memoryPolicy : additional) { if (memoryPolicy == null) { throw new IllegalArgumentException("Memory policy cannot be null."); } this.memoryPolicy |= memoryPolicy.index; } } return this; }
Source:
@Test public void forOverrideRequest() { Action action = mockAction(ASSET_KEY_1, ASSET_URI_1); AssetRequestHandler handler = new AssetRequestHandler(context); List<RequestHandler> handlers = new ArrayList<RequestHandler>(Arrays.asList(handler)); // must use non-mock constructor because that's where Picasso's list of handlers is created Picasso picasso = new Picasso(context, dispatcher, cache, null, null, handlers, stats, false, false); BitmapHunter hunter = forRequest(picasso, dispatcher, cache, stats, action); assertThat(hunter.requestHandler).isEqualTo(handler); }

Target:
@Test public void forOverrideRequest() { Action action = mockAction(ASSET_KEY_1, ASSET_URI_1); RequestHandler handler = new AssetRequestHandler(context); List<RequestHandler> handlers = Arrays.asList(handler); // Must use non-mock constructor because that is where Picasso's list of handlers is created. Picasso picasso = new Picasso(context, dispatcher, cache, null, null, handlers, stats, false, false); BitmapHunter hunter = forRequest(picasso, dispatcher, cache, stats, action); assertThat(hunter.requestHandler).isEqualTo(handler); }
Source:
static BitmapFactory.Options createBitmapOptions(Request data) { final boolean justBounds = data.hasSize(); final boolean hasConfig = data.config != null; final boolean instantiate = hasConfig || justBounds; // Only instantiate if we need it final BitmapFactory.Options options = instantiate ? new BitmapFactory.Options() : null; if (justBounds) { options.inJustDecodeBounds = true; } if (hasConfig) { options.inPreferredConfig = data.config; } return options; }

Target:
static BitmapFactory.Options createBitmapOptions(Request data) { final boolean justBounds = data.hasSize(); final boolean hasConfig = data.config != null; BitmapFactory.Options options = null; if (justBounds || hasConfig) { options = new BitmapFactory.Options(); options.inJustDecodeBounds = justBounds; if (hasConfig) { options.inPreferredConfig = data.config; } } return options; }
Source:
@Override public void onReceive(Context context, Intent intent) { // On some versions of Android this may be called with a null Intent if (null == intent) return; String action = intent.getAction(); Bundle extras = intent.getExtras(); if (ACTION_AIRPLANE_MODE_CHANGED.equals(action)) { dispatchAirplaneModeChange(extras.getBoolean(EXTRA_AIRPLANE_STATE, false)); } else if (CONNECTIVITY_ACTION.equals(action)) { dispatchNetworkStateChange(connectivityManager.getActiveNetworkInfo()); } }

Target:
@Override public void onReceive(Context context, Intent intent) { // On some versions of Android this may be called with a null Intent if (null == intent) { return; } String action = intent.getAction(); Bundle extras = intent.getExtras(); if (ACTION_AIRPLANE_MODE_CHANGED.equals(action)) { dispatchAirplaneModeChange(extras.getBoolean(EXTRA_AIRPLANE_STATE, false)); } else if (CONNECTIVITY_ACTION.equals(action)) { dispatchNetworkStateChange(connectivityManager.getActiveNetworkInfo()); } }
Source:
static long calculateDiskCacheSize(File dir) { long size = MIN_DISK_CACHE_SIZE; try { StatFs statFs = new StatFs(dir.getAbsolutePath()); long available = statFs.getBlockCount() * statFs.getBlockSize(); // Target 2% of the total space. size = available / 50; } catch (IllegalArgumentException ignored) { } // Bound inside min/max size for disk cache. return Math.max(Math.min(size, MAX_DISK_CACHE_SIZE), MIN_DISK_CACHE_SIZE); }

Target:
static long calculateDiskCacheSize(File dir) { long size = MIN_DISK_CACHE_SIZE; try { StatFs statFs = new StatFs(dir.getAbsolutePath()); long available = ((long) statFs.getBlockCount()) * statFs.getBlockSize(); // Target 2% of the total space. size = available / 50; } catch (IllegalArgumentException ignored) { } // Bound inside min/max size for disk cache. return Math.max(Math.min(size, MAX_DISK_CACHE_SIZE), MIN_DISK_CACHE_SIZE); }
Source:
Bitmap decodeAsset(Uri uri, PicassoBitmapOptions bitmapOptions) throws IOException { String path = uri.getPath().replaceFirst("/", ""); AssetManager assets = context.getAssets(); if (bitmapOptions != null && bitmapOptions.inJustDecodeBounds) { BitmapFactory.decodeStream(assets.open(path), null, bitmapOptions); calculateInSampleSize(bitmapOptions); } return decodeStream(assets.open(path), bitmapOptions); }

Target:
Bitmap decodeAsset(Uri uri, PicassoBitmapOptions bitmapOptions) throws IOException { String path = uri.getPath().substring(1); AssetManager assets = context.getAssets(); if (bitmapOptions != null && bitmapOptions.inJustDecodeBounds) { BitmapFactory.decodeStream(assets.open(path), null, bitmapOptions); calculateInSampleSize(bitmapOptions); } return decodeStream(assets.open(path), bitmapOptions); }
Source:
public <K,V> List<K> Keys(TreeMap<K,V> _map) { ArrayList<K> keys = new ArrayList<K>(); for(Map.Entry<K,V> entry : _map.entrySet()) { keys.add(entry.getKey()); } return keys; }

Target:
private <K,V> List<K> Keys(TreeMap<K,V> _map) { ArrayList<K> keys = new ArrayList<K>(); for(Map.Entry<K,V> entry : _map.entrySet()) { keys.add(entry.getKey()); } return keys; }
Source:
long ConvertMsTo24Bits(long timeMs) { long time24Bits = (long)(((timeMs << kAbsSendTimeFraction) + 500) / 1000) & 0x00FFFFFF; return time24Bits; }

Target:
private long ConvertMsTo24Bits(long timeMs) { long time24Bits = (long)(((timeMs << kAbsSendTimeFraction) + 500) / 1000) & 0x00FFFFFF; return time24Bits; }
Source:
boolean IsWithinClusterBounds(long sendDeltaMs, Cluster clusterAggregate) { if(clusterAggregate.count == 0) { return true; } double clusterMean = clusterAggregate.sendMeanMs / (double)clusterAggregate.count; return Math.abs((double)sendDeltaMs - clusterMean) < 2.5f; }

Target:
private boolean IsWithinClusterBounds(long sendDeltaMs, Cluster clusterAggregate) { if(clusterAggregate.count == 0) { return true; } double clusterMean = clusterAggregate.sendMeanMs / (double)clusterAggregate.count; return Math.abs((double)sendDeltaMs - clusterMean) < 2.5f; }
Source:
void addCluster(List<Cluster> clusters, Cluster cluster) { cluster.sendMeanMs /= (double)cluster.count; cluster.recvMeanMs /= (double)cluster.count; cluster.meanSize /= cluster.count; clusters.add(cluster); }

Target:
private void addCluster(List<Cluster> clusters, Cluster cluster) { cluster.sendMeanMs /= (double)cluster.count; cluster.recvMeanMs /= (double)cluster.count; cluster.meanSize /= cluster.count; clusters.add(cluster); }
Source:
public static boolean isKeyframe(ByteArrayBuffer baf) { if (baf.getLength() < 2) return false; // The data follows the one-byte header. byte b = baf.getBuffer()[baf.getOffset() + 1]; return (b & KF_MASK) != 0; }

Target:
public static boolean isKeyframe(ByteArrayBuffer baf) { if (baf == null || baf.getLength() < 2) { return false; } // The data follows the one-byte header. byte b = baf.getBuffer()[baf.getOffset() + 1]; return (b & KF_MASK) != 0; }
Source:
public Node node() { final Node castCache = Node.class.cast(this.cache); final Node answer; final boolean isDocument = castCache instanceof Document; if (isDocument) { answer = castCache.cloneNode(true); } else { answer = this.createImportedNode(castCache); } return answer; }

Target:
public Node node() { final Node castCache = Node.class.cast(this.cache); final Node answer; if (castCache instanceof Document) { answer = castCache.cloneNode(true); } else { answer = this.createImportedNode(castCache); } return answer; }
Source:
public void testRealBbcTxlogRegularExamples() { assertTxlogNitroScore("THE HOUSING ENFORCERS", "Episode 2", "The Housing Enforcers", scoreOnMatch); //will likely add equiv rules for this in future assertTxlogNitroScore("!MPOSSIBLE", "Episode 7", "Impossible", scoreOnMismatch); }

Target:
public void testRealBbcTxlogRegularExamples() { assertTxlogNitroScore("THE HOUSING ENFORCERS", "Episode 2", "The Housing Enforcers", scoreOnMatch); }
Source:
private static Process getProcess(IngesterName name) { Environment environment; try { environment = Environment.valueOf(TelescopeConfiguration.ENVIRONMENT); } catch (IllegalArgumentException e) { //add stage as the default environment, which is better than crashing log.error("Could not find a telescope environment with the given name, name={}. Falling back to STAGE.", TelescopeConfiguration.ENVIRONMENT); e.printStackTrace(); environment = Environment.STAGE; } return Process.create(name.getIngesterKey(), name.getIngesterName(), environment); }

Target:
private static Process getProcess(IngesterName name) { Environment environment; try { environment = Environment.valueOf(ENVIRONMENT); } catch (IllegalArgumentException e) { //add stage as the default environment, which is better than crashing environment = Environment.STAGE; log.error( "Could not find a telescope environment with the given name, name={}. Falling back to STAGE.", ENVIRONMENT, e ); } return Process.create(name.getIngesterKey(), name.getIngesterName(), environment); }
Source:
public void generatorCreatesCandidatesForNonExcludedUri() { Item item = new Item(); item.setId(12345678L); item.setCanonicalUri("notexcluded"); generators.generate(item, resultDescription); verify(generator).generate(item, resultDescription); }

Target:
public void generatorCreatesCandidatesForNonExcludedUri() { Item item = new Item(); item.setCanonicalUri("notexcluded"); generators.generate(item, resultDescription); verify(generator).generate(item, resultDescription); }
Source:
public void testConvertsPcOdToBrandIosUri() { map.put("dc:relation.programmeId", "338672-002"); Assert.assertThat( C4AtomApi.iOsUriFromPcUri("http://www.channel4.com/programmes/come-dine-with-me/on-demand/338672-002", map), is("all4://views/brands?brand=come-dine-with-me&programme=338672-002")); }

Target:
public void testConvertsPcOdToBrandIosUri() { map.put("dc:relation.programmeId", "338672-002"); assertThat( C4AtomApi.iOsUriFromPcUri("http://www.channel4.com/programmes/come-dine-with-me/on-demand/338672-002", map), is("all4://views/brands?brand=come-dine-with-me&programme=338672-002")); }
Source:
public C4AtomEntryVersionExtractor(Optional<Platform> platform, C4LocationPolicyIds locationPolicyIds, boolean createIosBrandLocations) { this.platform = checkNotNull(platform); this.locationPolicyIds = checkNotNull(locationPolicyIds); this.createIosBrandLocations = checkNotNull(createIosBrandLocations); }

Target:
public C4AtomEntryVersionExtractor(Optional<Platform> platform, C4LocationPolicyIds locationPolicyIds, boolean createIosBrandLocations) { this.platform = checkNotNull(platform); this.locationPolicyIds = checkNotNull(locationPolicyIds); this.createIosBrandLocations = createIosBrandLocations; }
Source:
public BaseContentPopulator(Optional<RoviProgramLine> program, Iterable<RoviProgramDescriptionLine> descriptions, ContentResolver contentResolver) { checkArgument(!isDelete(program), "It's not possible to populate from a program delete action"); checkNotNull(descriptions); checkNotNull(contentResolver); this.optionalProgram = program; this.descriptions = descriptions; this.contentResolver = contentResolver; }

Target:
public BaseContentPopulator(Optional<RoviProgramLine> program, Iterable<RoviProgramDescriptionLine> descriptions, ContentResolver contentResolver) { checkArgument(!isDelete(program), "It's not possible to populate from a program delete action"); this.optionalProgram = checkNotNull(program); this.descriptions = checkNotNull(descriptions); this.contentResolver = checkNotNull(contentResolver); }
Source:
public ASTNode() { this((FileLocation)null); location = null; }

Target:
public ASTNode() { this((FileLocation)null); }
Source:
public Set<String> getFreeVariables() { // Get free variables in the sub-expressions. Set<String> freeVars = toReplace.getFreeVariables(); freeVars.addAll(inExpr.getFreeVariables()); // Remove the name that just became bound. freeVars.remove(varName); return freeVars; }

Target:
public Set<String> getFreeVariables() { return toReplace.getFreeVariables(); }
Source:
public Set<String> getFreeVariables() { // Get all free variables in the body of the method. Set<String> freeVars = body.getFreeVariables(); // Remove variables that became bound in this method's scope. freeVars.remove(this.getName()); for (FormalArg farg : formalArgs) { freeVars.remove(farg.getName()); } return freeVars; }

Target:
public Set<String> getFreeVariables() { // Get all free variables in the body of the method. Set<String> freeVars = body.getFreeVariables(); // Remove variables that became bound in this method's scope. for (FormalArg farg : formalArgs) { freeVars.remove(farg.getName()); } return freeVars; }
Source:
public boolean isTrue(ZestResponse response) { boolean toReturn = true; for (ZestExpressionElement con : getChildrenCondition()) { toReturn = toReturn && con.evaluate(response);// compute AND for each child if(!toReturn) break;//lazy evaluation } return toReturn; }

Target:
public boolean isTrue(ZestResponse response) { if(getChildrenCondition().isEmpty()) return false; boolean toReturn = true; for (ZestExpressionElement con : getChildrenCondition()) { toReturn = toReturn && con.evaluate(response);// compute AND for each child if(!toReturn) break;//lazy evaluation } return toReturn; }
Source:
private String getGMTOffsetString(long millis) { long absmillis = (millis < 0) ? -millis : millis; int minutes = (int) ((absmillis / (1000 * 60)) % 60); int hours = (int) ((absmillis / (1000 * 60 * 60)) % 24); return String.format("(GMT%c%02d:%02d) ", millis >= 0 ? '+' : '-', hours, minutes) }

Target:
private String getGMTOffsetString(long millis) { long absmillis = (millis < 0) ? -millis : millis; int minutes = (int) ((absmillis / (1000 * 60)) % 60); int hours = (int) ((absmillis / (1000 * 60 * 60)) % 24); return String.format("(GMT%c%02d:%02d) ", millis >= 0 ? '+' : '-', hours, minutes); }
Source:
private static boolean isPositiveInteger(final String str) { if (str == null || str.isEmpty()) { return false; } // numbers/versions with leading zeros should not be treated as numbers // (e.g. when comparing "01" <-> "1") if (str.charAt(0) == '0') { return false; } for (int i = 0; i < str.length(); i++) { final char c = str.charAt(i); if (c < '0' || c > '9') { return false; } } return true; }

Target:
static boolean isPositiveInteger(final String str) { if (str == null || str.isEmpty()) { return false; } // numbers with leading zeros should not be treated as numbers // (e.g. when comparing "01" <-> "1") if (str.charAt(0) == '0' && str.length() > 1) { return false; } for (int i = 0; i < str.length(); i++) { final char c = str.charAt(i); if (c < '0' || c > '9') { return false; } } return true; }
Source:
private void lookupDatabase() { try { log.tracef( "Retrieving MongoDatabase from JNDI at %1$s", config.getNativeClientResource() ); mongoDb = (MongoDatabase) jndiService.locate( config.getNativeClientResource() ); } catch (RuntimeException e) { throw log.errorOnFetchJndiClientProperty( config.getNativeClientResource() ); } // clear resources this.jndiService = null; }

Target:
private void lookupDatabase() { try { log.tracef( "Retrieving MongoDatabase from JNDI at %1$s", config.getNativeClientResource() ); mongoDb = (MongoDatabase) jndiService.locate( config.getNativeClientResource() ); } catch (RuntimeException e) { throw log.errorOnFetchJndiClientProperty( config.getNativeClientResource() ); } }
Source:
private void lookupClient() { try { log.tracef( "Retrieving MongoDatabase from JNDI at %1$s", configuration.getNativeClientResource() ); Driver driver = (Driver) jndiService.locate( configuration.getNativeClientResource() ); this.client = new BoltNeo4jClient( driver ); } catch (RuntimeException e) { throw log.errorOnFetchJndiClientProperty( configuration.getNativeClientResource() ); } // clear resources this.jndiService = null; }

Target:
private void lookupClient() { try { log.tracef( "Retrieving MongoDatabase from JNDI at %1$s", configuration.getNativeClientResource() ); Driver driver = (Driver) jndiService.locate( configuration.getNativeClientResource() ); this.client = new BoltNeo4jClient( driver ); } catch (RuntimeException e) { throw log.errorOnFetchJndiClientProperty( configuration.getNativeClientResource() ); } }
Source:
public void before() throws Exception { // Synchronize on the static field to defend against concurrent launches, // e.g. the usage as JUnit Rule concurrently with the usage as global test listener in Surefire. synchronized ( running ) { if ( running.compareAndSet( false, true ) ) { RemoteHotRodServerHelper.beforeRun(); StandaloneCommandBuilder builder = StandaloneCommandBuilder .of( "target/infinispan-server" ); builder .setServerReadOnlyConfiguration( DEFAULT_CONFIG_PATH ); if ( portOffset != 0 ) { builder.addJavaOption( "-Djboss.socket.binding.port-offset=" + portOffset ); } Launcher launcher = Launcher.of( builder ); hotRodServer = launcher.inherit().launch(); waitForRunning(); } } }

Target:
public void before() throws Exception { // Synchronize on the static field to defend against concurrent launches, // e.g. the usage as JUnit Rule concurrently with the usage as global test listener in Surefire. synchronized ( running ) { if ( running.compareAndSet( false, true ) ) { StandaloneCommandBuilder builder = StandaloneCommandBuilder .of( "target/infinispan-server" ); builder .setServerReadOnlyConfiguration( DEFAULT_CONFIG_PATH ); if ( portOffset != 0 ) { builder.addJavaOption( "-Djboss.socket.binding.port-offset=" + portOffset ); } Launcher launcher = Launcher.of( builder ); //This will launch the server w/o redirecting stdin and stdout, as that would corrupt Surefire's own streams when running via Maven. //Might want to use launcher.inherit().launch instead if you need to debug server bootstrap. hotRodServer = launcher.launch(); waitForRunning(); } } }
Source:
public Rule Reserved() { return FirstOf( Aggregate(), Find(), FindOne(), FindAndModify(), Insert(), Remove(), Update(), Count() ); // TODO There are many more query types than what we support. }

Target:
public Rule Reserved() { return FirstOf( Find(), FindOne(), FindAndModify(), Insert(), Remove(), Update(), Count(), Aggregate() ); // TODO There are many more query types than what we support. }
Source:
public Rule Reserved() { return FirstOf( Sequence( Find(), builder.setOperation( Operation.FIND ) ), Sequence( Count(), builder.setOperation( Operation.COUNT ) ) ); //TODO there is many more than `find` an `count` but as this time we only support `find` and `count` }

Target:
public Rule Reserved() { return FirstOf( Find(), Count() ); //TODO there is many more than `find` an `count` but as this time we only support `find` and `count` }