id
int64
1
49k
buggy
stringlengths
34
37.5k
fixed
stringlengths
2
37k
401
final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final String value = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { <BUG>case APPLIES_TO_VERSION: builder.addAppliesTo(value); break;</BUG> case RESULTING_VERSION: if(type == Patch.PatchType.CUMULATIVE) {
[DELETED]
402
final StringBuilder path = new StringBuilder(); for(final String p : item.getPath()) { path.append(p).append(PATH_DELIMITER); } path.append(item.getName()); <BUG>writer.writeAttribute(Attribute.PATH.name, path.toString()); if(type != ModificationType.REMOVE) {</BUG> writer.writeAttribute(Attribute.HASH.name, bytesToHexString(item.getContentHash())); } if(type != ModificationType.ADD) {
if (item.isDirectory()) { writer.writeAttribute(Attribute.DIRECTORY.name, "true"); if(type != ModificationType.REMOVE) {
403
package org.jboss.as.patching; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.patching.runner.PatchingException; import org.jboss.logging.Messages; import org.jboss.logging.annotations.Message; <BUG>import org.jboss.logging.annotations.MessageBundle; import java.io.IOException;</BUG> import java.util.List; @MessageBundle(projectCode = "JBAS") public interface PatchMessages {
import org.jboss.logging.annotations.Cause; import java.io.IOException;
404
catch (Exception e) { log.log(Level.WARNING, "Failed to export mail " + tempFile, e); } } else { <BUG>File destFile = makeUniqueExportFileName(dir, tempFile); </BUG> if (log.isLoggable(Level.INFO)) log.info("Export issue attachment to destFile=" + destFile); if (!destFile.exists()) { Files.copy(tempFile.toPath(), destFile.toPath());
File destFile = makeUniqueExportFileName(dir, tempFile, cbSave.createChild(0.5));
405
package com.google.cloud.tools.eclipse.login; import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl; import com.google.cloud.tools.eclipse.login.ui.LoginServiceUi; <BUG>import com.google.cloud.tools.ide.login.Account; import com.google.cloud.tools.ide.login.GoogleLoginState; import com.google.cloud.tools.ide.login.JavaPreferenceOAuthDataStore; import com.google.cloud.tools.ide.login.LoggerFacade; import com.google.cloud.tools.ide.login.OAuthDataStore; import com.google.common.annotations.VisibleForTesting;</BUG> import java.util.Arrays;
import com.google.cloud.tools.login.Account; import com.google.cloud.tools.login.GoogleLoginState; import com.google.cloud.tools.login.JavaPreferenceOAuthDataStore; import com.google.cloud.tools.login.LoggerFacade; import com.google.cloud.tools.login.OAuthDataStore; import com.google.common.annotations.VisibleForTesting;
406
package com.google.cloud.tools.eclipse.login.ui; import com.google.api.client.auth.oauth2.Credential; import com.google.api.client.util.Strings; import com.google.cloud.tools.eclipse.login.IGoogleLoginService; <BUG>import com.google.cloud.tools.ide.login.Account; import com.google.common.annotations.VisibleForTesting;</BUG> import java.util.ArrayList; import java.util.Collections; import java.util.Comparator;
import com.google.cloud.tools.login.Account; import com.google.common.annotations.VisibleForTesting;
407
import static org.mockito.Mockito.when; import com.google.api.client.auth.oauth2.Credential; import com.google.cloud.tools.eclipse.login.IGoogleLoginService; import com.google.cloud.tools.eclipse.login.ui.AccountSelectorObservableValue; import com.google.cloud.tools.eclipse.test.util.ui.ShellTestResource; <BUG>import com.google.cloud.tools.ide.login.Account; import java.util.Arrays;</BUG> import java.util.HashSet; import org.eclipse.core.databinding.ValidationStatusProvider; import org.eclipse.core.resources.IProject;
import com.google.cloud.tools.login.Account; import java.util.Arrays;
408
package com.google.cloud.tools.eclipse.login; <BUG>import com.google.cloud.tools.ide.login.Account; import java.util.Set;</BUG> public interface IGoogleLoginService { Account logIn(String dialogMessage); void logOutAll();
import com.google.cloud.tools.login.Account; import java.util.Set;
409
package com.google.cloud.tools.eclipse.login.ui; import static org.junit.Assert.assertEquals; <BUG>import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull;</BUG> import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; import com.google.cloud.tools.eclipse.login.IGoogleLoginService;
[DELETED]
410
import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; <BUG>import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List;</BUG> @RunWith(MockitoJUnitRunner.class)
[DELETED]
411
} @Test public void testLogOutButton_notLoggedIn() {</BUG> setUpLoginService(); AccountsPanel panel = new AccountsPanel(null, loginService); <BUG>panel.createDialogArea(shell); assertNull(panel.logOutButton); }</BUG> @Test
@Test(expected = WidgetNotFoundException.class) public void testLogOutButton_notLoggedIn() { Control control = panel.createDialogArea(shell); new SWTBot(control).buttonWithId(AccountsPanel.CSS_CLASS_NAME_KEY, "logOutButton");
412
}</BUG> @Test public void testLogOutButton_loggedIn() { setUpLoginService(Arrays.asList(account1)); AccountsPanel panel = new AccountsPanel(null, loginService); <BUG>panel.createDialogArea(shell); assertNotNull(panel.logOutButton); } @Test public void testAccountsArea_zeroAccounts() {</BUG> setUpLoginService();
@Test(expected = WidgetNotFoundException.class) public void testLogOutButton_notLoggedIn() { Control control = panel.createDialogArea(shell); new SWTBot(control).buttonWithId(AccountsPanel.CSS_CLASS_NAME_KEY, "logOutButton");
413
} @Test public void testAccountsArea_zeroAccounts() {</BUG> setUpLoginService(); AccountsPanel panel = new AccountsPanel(null, loginService); <BUG>panel.createDialogArea(shell); assertTrue(panel.accountLabels.isEmpty()); } @Test public void testAccountsArea_oneAccount() {</BUG> setUpLoginService(Arrays.asList(account1));
@Test(expected = WidgetNotFoundException.class) public void testLogOutButton_notLoggedIn() {
414
} @Test public void testAccountsArea_oneAccount() {</BUG> setUpLoginService(Arrays.asList(account1)); AccountsPanel panel = new AccountsPanel(null, loginService); <BUG>panel.createDialogArea(shell); assertEquals(1, panel.accountLabels.size()); panel.accountLabels.get(0).getText().contains(account2.getEmail()); } @Test public void testAccountsArea_threeAccounts() {</BUG> setUpLoginService(Arrays.asList(account1, account2, account3));
@Test(expected = WidgetNotFoundException.class) public void testLogOutButton_notLoggedIn() { setUpLoginService(); Control control = panel.createDialogArea(shell); new SWTBot(control).buttonWithId(AccountsPanel.CSS_CLASS_NAME_KEY, "logOutButton");
415
import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.when; import com.google.api.client.auth.oauth2.Credential; import com.google.cloud.tools.eclipse.login.IGoogleLoginService; import com.google.cloud.tools.eclipse.test.util.ui.ShellTestResource; <BUG>import com.google.cloud.tools.ide.login.Account; import java.util.Arrays;</BUG> import java.util.HashSet; import java.util.LinkedHashSet; import org.eclipse.swt.widgets.Shell;
import com.google.cloud.tools.login.Account; import java.util.Arrays;
416
package com.google.cloud.tools.eclipse.login.ui; import com.google.cloud.tools.eclipse.login.IGoogleLoginService; import com.google.cloud.tools.eclipse.login.Messages; <BUG>import com.google.cloud.tools.ide.login.Account; import com.google.common.annotations.VisibleForTesting;</BUG> import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.PopupDialog; import org.eclipse.jface.layout.GridDataFactory;
import com.google.cloud.tools.login.Account; import com.google.common.annotations.VisibleForTesting;
417
import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; <BUG>import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Button;</BUG> import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button;
418
package wew.water.gpf; <BUG>import org.esa.beam.framework.gpf.OperatorException; public class ChlorophyllNetworkOperation implements NeuralNetworkOperation { @Override public void compute(float[] in, float[] out, int mask, int errMask, float a) {</BUG> if(in.length != getNumberOfInputNodes()) {
public class ChlorophyllNetworkOperation { public static int compute(float[] in, float[] out) {
419
if(in.length != getNumberOfInputNodes()) { throw new IllegalArgumentException("Wrong input array size"); } if(out.length != getNumberOfOutputNodes()) { throw new IllegalArgumentException("Wrong output array size"); <BUG>} NeuralNetworkComputer.compute(in, out, mask, errMask, a, </BUG> NeuralNetworkConstants.INPUT_SCALE_LIMITS, NeuralNetworkConstants.INPUT_SCALE_OFFSET_FACTORS,
final int[] rangeCheckErrorMasks = { WaterProcessorOp.RESULT_ERROR_VALUES[1], WaterProcessorOp.RESULT_ERROR_VALUES[2] }; return NeuralNetworkComputer.compute(in, out, rangeCheckErrorMasks,
420
+4.332827e-01, +4.453712e-01, -2.355489e-01, +4.329192e-02, -3.259577e-02, +4.245090e-01, -1.132328e-01, +2.511418e-01, -1.995074e-01, +1.797701e-01, -3.817864e-01, +2.854951e-01, }, }; <BUG>private final double[][] input_hidden_weights = new double[][]{ </BUG> { -5.127986e-01, +5.872741e-01, +4.411426e-01, +1.344507e+00, -7.758738e-01, -7.235078e-01, +2.421909e+00, +1.923607e-02,
private static final double[][] input_hidden_weights = new double[][]{
421
-1.875955e-01, +7.851294e-01, -1.226189e+00, -1.852845e-01, +9.392875e-01, +9.886471e-01, +8.400441e-01, -1.657109e+00, +8.292500e-01, +6.291445e-01, +1.855838e+00, +7.817575e-01, }, }; <BUG>private final double[][] input_intercept_and_slope = new double[][]{ </BUG> {+4.165578e-02, +1.161174e-02}, {+3.520901e-02, +1.063665e-02}, {+2.920864e-02, +1.050035e-02},
private static final double[][] input_intercept_and_slope = new double[][]{
422
{+2.468300e-01, +8.368545e-01}, {-6.613120e-01, +1.469582e+00}, {-6.613120e-01, +1.469582e+00}, {+7.501110e-01, +2.776545e-01}, }; <BUG>private final double[][] output_weights = new double[][]{ </BUG> {-6.498447e+00,}, {-1.118659e+01,}, {+7.141798e+00,},
private static final double[][] output_weights = new double[][]{
423
package wew.water.gpf; public class NeuralNetworkComputer { <BUG>public static void compute(float[] in, float[] out, int mask, int errMask, float a, </BUG> double[][] input_scale_limits, double[] input_scale_offset_factors, int[] input_scale_flag,
public static int compute(float[] in, float[] out, int[] rangeCheckErrorMasks,
424
package wew.water.gpf; <BUG>public class AtmosphericCorrectionNetworkOperation implements NeuralNetworkOperation { @Override public void compute(float[] in, float[] out, int mask, int errMask, float a) { if(in.length != getNumberOfInputNodes()) { </BUG> throw new IllegalArgumentException("Wrong input array size");
import java.util.Arrays; public class AtmosphericCorrectionNetworkOperation { public static int compute(float[] in, float[] out) { if (in.length != getNumberOfInputNodes()) {
425
</BUG> R result = seed; for (Map.Entry<E, MutableLong> entry : valueMap.entrySet()) { result = accumulator.apply(result, entry.getKey(), entry.getValue().value()); <BUG>if (predicate.test(entry.getKey(), entry.getValue().value(), result) == false) { </BUG> break; } } return result;
public void forEach(BiConsumer<? super E, Long> action) { action.accept(entry.getKey(), entry.getValue().value()); public <R> R forEach(final R seed, TriFunction<R, ? super E, Long, R> accumulator, final TriPredicate<? super E, Long, ? super R> conditionToBreak) { if (conditionToBreak.test(entry.getKey(), entry.getValue().value(), result)) {
426
public MutableDouble setValue(final double value) { this.value = value; return this; } public double getAndSet(final double value) { <BUG>double result = value; </BUG> this.value = value; return result; }
final double result = this.value;
427
this.value = value; return result; } public double setAndGet(final double value) { this.value = value; <BUG>return value; </BUG> } public boolean isNaN() { return Double.isNaN(value);
return this; public double getAndSet(final double value) { final double result = this.value; return this.value;
428
<R> R forEach(Collection<String> columnNames, int fromRowIndex, int toRowIndex, R seed, BiFunction<R, ? super Object[], R> accumulator, BiPredicate<? super Object[], ? super R> predicate); </BUG> <R> R forEach(Collection<String> columnNames, int fromRowIndex, int toRowIndex, R seed, BiFunction<R, ? super Object[], R> accumulator, <BUG>BiPredicate<? super Object[], ? super R> predicate, boolean shareRowArray); </BUG> Object[][] toArray(); Object[][] toArray(int fromRowIndex, int toRowIndex); <T> T[] toArray(Class<? extends T> rowClass); <T> T[] toArray(Class<? extends T> rowClass, int fromRowIndex, int toRowIndex);
BiPredicate<? super Object[], ? super R> conditionToBreak); BiPredicate<? super Object[], ? super R> conditionToBreak, boolean shareRowArray);
429
public MutableChar setValue(final char value) { this.value = value; return this; } public char getAndSet(final char value) { <BUG>char result = value; </BUG> this.value = value; return result; }
final char result = this.value;
430
this.value = value; return result; } public char setAndGet(final char value) { this.value = value; <BUG>return value; </BUG> } public void increment() { value++;
return this; public char getAndSet(final char value) { final char result = this.value; return this.value;
431
</BUG> R result = seed; for (Map.Entry<E, MutableInt> entry : valueMap.entrySet()) { result = accumulator.apply(result, entry.getKey(), entry.getValue().value()); <BUG>if (predicate.test(entry.getKey(), entry.getValue().value(), result) == false) { </BUG> break; } } return result;
public void forEach(BiConsumer<? super E, Integer> action) { action.accept(entry.getKey(), entry.getValue().value()); public <R> R forEach(final R seed, TriFunction<R, ? super E, Integer, R> accumulator, final TriPredicate<? super E, Integer, ? super R> conditionToBreak) { if (conditionToBreak.test(entry.getKey(), entry.getValue().value(), result)) {
432
public MutableBoolean setValue(final boolean value) { this.value = value; return this; } public boolean getAndSet(final boolean value) { <BUG>boolean result = value; </BUG> this.value = value; return result; }
final boolean result = this.value;
433
this.value = value; return result; } public boolean setAndGet(final boolean value) { this.value = value; <BUG>return value; </BUG> } public void setFalse() { this.value = false;
return this; public boolean getAndSet(final boolean value) { final boolean result = this.value; return this.value;
434
public MutableFloat setValue(final float value) { this.value = value; return this; } public float getAndSet(final float value) { <BUG>float result = value; </BUG> this.value = value; return result; }
final float result = this.value;
435
this.value = value; return result; } public float setAndGet(final float value) { this.value = value; <BUG>return value; </BUG> } public boolean isNaN() { return Float.isNaN(value);
return this; public float getAndSet(final float value) { final float result = this.value; return this.value;
436
public MutableByte setValue(final byte value) { this.value = value; return this; } public byte getAndSet(final byte value) { <BUG>byte result = value; </BUG> this.value = value; return result; }
final byte result = this.value;
437
this.value = value; return result; } public byte setAndGet(final byte value) { this.value = value; <BUG>return value; </BUG> } public void increment() { value++;
return this; public byte getAndSet(final byte value) { final byte result = this.value; return this.value;
438
public MutableLong setValue(final long value) { this.value = value; return this; } public long getAndSet(final long value) { <BUG>long result = value; </BUG> this.value = value; return result; }
final long result = this.value;
439
this.value = value; return result; } public long setAndGet(final long value) { this.value = value; <BUG>return value; </BUG> } public void increment() { value++;
return this; public long getAndSet(final long value) { final long result = this.value; return this.value;
440
public MutableInt setValue(final int value) { this.value = value; return this; } public int getAndSet(final int value) { <BUG>int result = value; </BUG> this.value = value; return result; }
final int result = this.value;
441
this.value = value; return result; } public int setAndGet(final int value) { this.value = value; <BUG>return value; </BUG> } public void increment() { value++;
return this; public int getAndSet(final int value) { final int result = this.value; return this.value;
442
} @RootTask static Task<Exec.Result> exec(String parameter, int number) { Task<String> task1 = MyTask.create(parameter); Task<Integer> task2 = Adder.create(number, number + 2); <BUG>return Task.ofType(Exec.Result.class).named("exec", "/bin/sh") .in(() -> task1)</BUG> .in(() -> task2) .process(Exec.exec((str, i) -> args("/bin/sh", "-c", "\"echo " + i + "\""))); }
return Task.named("exec", "/bin/sh").ofType(Exec.Result.class) .in(() -> task1)
443
return args; } static class MyTask { static final int PLUS = 10; static Task<String> create(String parameter) { <BUG>return Task.ofType(String.class).named("MyTask", parameter) .in(() -> Adder.create(parameter.length(), PLUS))</BUG> .in(() -> Fib.create(parameter.length())) .process((sum, fib) -> something(parameter, sum, fib)); }
return Task.named("MyTask", parameter).ofType(String.class) .in(() -> Adder.create(parameter.length(), PLUS))
444
final String instanceField = "from instance"; final TaskContext context = TaskContext.inmem(); final AwaitingConsumer<String> val = new AwaitingConsumer<>(); @Test public void shouldJavaUtilSerialize() throws Exception { <BUG>Task<Long> task1 = Task.ofType(Long.class).named("Foo", "Bar", 39) .process(() -> 9999L); Task<String> task2 = Task.ofType(String.class).named("Baz", 40) .in(() -> task1)</BUG> .ins(() -> singletonList(task1))
Task<Long> task1 = Task.named("Foo", "Bar", 39).ofType(Long.class) Task<String> task2 = Task.named("Baz", 40).ofType(String.class) .in(() -> task1)
445
assertEquals(des.id().name(), "Baz"); assertEquals(val.awaitAndGet(), "[9999] hello 10004"); } @Test(expected = NotSerializableException.class) public void shouldNotSerializeWithInstanceFieldReference() throws Exception { <BUG>Task<String> task = Task.ofType(String.class).named("WithRef") .process(() -> instanceField + " causes an outer reference");</BUG> serialize(task); } @Test
Task<String> task = Task.named("WithRef").ofType(String.class) .process(() -> instanceField + " causes an outer reference");
446
serialize(task); } @Test public void shouldSerializeWithLocalReference() throws Exception { String local = instanceField; <BUG>Task<String> task = Task.ofType(String.class).named("WithLocalRef") .process(() -> local + " won't cause an outer reference");</BUG> serialize(task); Task<String> des = deserialize(); context.evaluate(des).consume(val);
Task<String> task = Task.named("WithLocalRef").ofType(String.class) .process(() -> local + " won't cause an outer reference");
447
} @RootTask public static Task<String> standardArgs(int first, String second) { firstInt = first; secondString = second; <BUG>return Task.ofType(String.class).named("StandardArgs", first, second) .process(() -> second + " " + first * 100);</BUG> } @Test public void shouldParseFlags() throws Exception {
return Task.named("StandardArgs", first, second).ofType(String.class) .process(() -> second + " " + first * 100);
448
assertThat(parsedEnum, is(CustomEnum.BAR)); } @RootTask public static Task<String> enums(CustomEnum enm) { parsedEnum = enm; <BUG>return Task.ofType(String.class).named("Enums", enm) .process(enm::toString);</BUG> } @Test public void shouldParseCustomTypes() throws Exception {
return Task.named("Enums", enm).ofType(String.class) .process(enm::toString);
449
assertThat(parsedType.content, is("blarg parsed for you!")); } @RootTask public static Task<String> customType(CustomType myType) { parsedType = myType; <BUG>return Task.ofType(String.class).named("Types", myType.content) .process(() -> myType.content);</BUG> } public enum CustomEnum { BAR
return Task.named("Types", myType.content).ofType(String.class) .process(() -> myType.content);
450
TaskContext taskContext = TaskContext.inmem(); TaskContext.Value<Long> value = taskContext.evaluate(fib92); value.consume(f92 -> System.out.println("fib(92) = " + f92)); } static Task<Long> create(long n) { <BUG>TaskBuilder<Long> fib = Task.ofType(Long.class).named("Fib", n); </BUG> if (n < 2) { return fib .process(() -> n);
TaskBuilder<Long> fib = Task.named("Fib", n).ofType(Long.class);
451
private List<Processor> processors = new ArrayList<>(); private List<MetacodeContextImpl> metacodeContextList = new ArrayList<>(500); private MetasitoryWriter metasitoryWriter; private int round = 0; private int blankRounds = 0; <BUG>private long ts; </BUG> private final Properties properties = new Properties(); private Properties utdProperties = null; private String relateToPath = null;
private long ts = 0;
452
metasitoryWriter.close(); if (utdProperties != null) { saveUtdProperties(); } } <BUG>if (blankRounds == 1) { logger.debug(String.format("built in %dms", System.currentTimeMillis() - ts)); </BUG> }
if (blankRounds == 1 && ts > 0) { logger.note(String.format("Metacode built in %dms", System.currentTimeMillis() - ts));
453
MetacodeContextImpl context = Iterables.find(metacodeContextList, new MasterTypePredicate(masterTypeElement), null); if (context == null) { context = new MetacodeContextImpl(elementUtils, masterTypeElement); metacodeContextList.add(context); <BUG>logger.debug(" master - " + context.masterElement.toString()); logger.debug(" metacode - " + context.metacodeCanonicalName); </BUG> } context.metacodeAnnotations().add(annotation);
logger.debug(" metacode: " + context.metacodeCanonicalName);
454
Path source = Paths.get(sourceJavaFile.toUri()); Files.delete(source); sourceJavaFile.openWriter().close(); Files.delete(source); Path target = Paths.get(getUtdDirPath() + context.metacodeCanonicalName + ".utd"); <BUG>Files.createLink(source, target); logger.debug(" * " + context.metacodeCanonicalName + " up-to-date"); context.processorEnvironments.clear(); continue;</BUG> } catch (IOException e) {
if(debug) logger.note(" * " + context.metacodeCanonicalName + " up-to-date"); metasitoryWriter.write(context); iter.remove(); continue;
455
} catch (IOException e) { throw new RuntimeException("failed to create link to .utd file", e); } } } <BUG>} logger.debug(" + " + context.metacodeCanonicalName); </BUG> ClassName masterClassName = ClassName.get(context.masterElement); TypeSpec.Builder builder = TypeSpec.classBuilder(context.metacodeSimpleName)
if(debug) logger.note(" + " + context.metacodeCanonicalName);
456
.addModifiers(Modifier.PUBLIC) .returns(ParameterizedTypeName.get(ClassName.get(Class.class), masterClassName)) .addStatement("return $T.class", masterClassName).build()); context.builder = builder; } <BUG>if (utdPropertiesCopy != null && !utdPropertiesCopy.isEmpty()) { if (properties.getProperty("utd.cleanup", "true").equals("true")) { for (Object key : utdPropertiesCopy.keySet()) {</BUG> String metacodeCanonicalName = (String) key;
if (utdPropertiesCopy != null && !utdPropertiesCopy.isEmpty() && for (Object key : utdPropertiesCopy.keySet()) {
457
try { FileObject file = processingEnv.getFiler().getResource( StandardLocation.SOURCE_OUTPUT, (dot > 0 ? metacodeCanonicalName.substring(0, dot) : ""), (dot > 0 ? metacodeCanonicalName.substring(dot + 1) : metacodeCanonicalName) + ".java"); <BUG>if (new File(file.toUri()).delete()) { logger.debug(" - " + metacodeCanonicalName + " removed"); </BUG> utdProperties.remove(metacodeCanonicalName); } else {
if(debug) logger.note(" - " + metacodeCanonicalName + " removed");
458
} } catch (IOException e) { logger.warn("failed to cleanup metacode file: " + metacodeCanonicalName + " error: " + e.getMessage()); } } <BUG>} utdPropertiesCopy.clear();</BUG> } } private boolean processMetacodes(RoundEnvironment roundEnv) {
[DELETED]
459
generateHeader(relationName, out); generateInstances(document, appName, out); } public void scan(Document document, final String appName) throws MissingNodeException, IOException { List<Element> bugInstanceList = getBugInstanceList(document); <BUG>for (final Element element : bugInstanceList) { scanAttributeList(new AttributeCallback() {</BUG> public void apply(Attribute attribute) throws MissingNodeException { attribute.scan(element, appName); }
for (Iterator<Element> i = bugInstanceList.iterator(); i.hasNext(); ) { final Element element = (Element) i.next(); scanAttributeList(new AttributeCallback() {
460
private Document document; public XPathFind(Document document) { this.document = document; } public void find(String xpath) { <BUG>for (Node node : (Iterable<Node>) document.selectNodes(xpath)) { match(node); }</BUG> } protected abstract void match(Node node);
for (Iterator<Node> i = document.selectNodes(xpath).iterator(); i.hasNext(); ) { match(i.next());
461
package edu.umd.cs.findbugs; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; <BUG>import java.util.HashSet; import java.util.List;</BUG> import java.util.Locale; import java.util.Set; import org.dom4j.Document;
import java.util.Iterator; import java.util.List;
462
throw new PluginException("Could not instantiate detector class: " + e, e); } Node orderingConstraintsNode = pluginDescriptor.selectSingleNode("/FindbugsPlugin/OrderingConstraints"); if (orderingConstraintsNode != null) { <BUG>for (Element constraintElement : (Iterable<Element>) orderingConstraintsNode.selectNodes("./SplitPass|./WithinPass")) { DetectorFactorySelector earlierSelector = getConstraintSelector(</BUG> constraintElement, plugin, "Earlier", "EarlierCategory"); DetectorFactorySelector laterSelector = getConstraintSelector(
for (Iterator<Element> i = orderingConstraintsNode.selectNodes("./SplitPass|./WithinPass").iterator(); i.hasNext();) { Element constraintElement = i.next(); DetectorFactorySelector earlierSelector = getConstraintSelector(
463
List<String> uri = new ArrayList<String>(); uri.add("resources"); uri.add(resourceType); if (type != null) uri.add(type); <BUG>return callApi(HttpMethod.GET, uri, ObjectUtils.only(options, "next_cursor", "direction", "max_results", "prefix", "tags", "context", "moderations", "start_at"), options); }</BUG> public ApiResponse resourcesByTag(String tag, Map options) throws Exception { if (options == null) options = ObjectUtils.emptyMap();
ApiResponse response = callApi(HttpMethod.GET, uri, ObjectUtils.only(options, "next_cursor", "direction", "max_results", "prefix", "tags", "context", "moderations", "start_at"), options); addAccessModeToResponse(response,"public"); return response; }
464
if (options == null) options = ObjectUtils.emptyMap(); String resourceType = ObjectUtils.asString(options.get("resource_type"), "image"); String type = ObjectUtils.asString(options.get("type"), "upload"); Map params = ObjectUtils.only(options, "tags", "context", "moderations"); params.put("public_ids", publicIds); <BUG>return callApi(HttpMethod.GET, Arrays.asList("resources", resourceType, type), params, options); }</BUG> public ApiResponse resourcesByModeration(String kind, String status, Map options) throws Exception { if (options == null) options = ObjectUtils.emptyMap();
return callApi(HttpMethod.GET, Arrays.asList("resources"), ObjectUtils.emptyMap(), options); } public ApiResponse resources(Map options) throws Exception {
465
String resourceType = ObjectUtils.asString(options.get("resource_type"), "image"); String type = ObjectUtils.asString(options.get("type"), "upload"); Map params = new HashMap<String, Object>(); Util.processWriteParameters(options, params); params.put("moderation_status", options.get("moderation_status")); <BUG>return callApi(HttpMethod.POST, Arrays.asList("resources", resourceType, type, public_id), params, options); }</BUG> public ApiResponse deleteResources(Iterable<String> publicIds, Map options) throws Exception {
String type = ObjectUtils.asString(options.get("type")); List<String> uri = new ArrayList<String>(); uri.add("resources"); uri.add(resourceType); if (type != null) uri.add(type); ApiResponse response = callApi(HttpMethod.GET, uri, ObjectUtils.only(options, "next_cursor", "direction", "max_results", "prefix", "tags", "context", "moderations", "start_at"), options); addAccessModeToResponse(response,"public"); return response; } public ApiResponse resourcesByTag(String tag, Map options) throws Exception {
466
options = ObjectUtils.emptyMap(); String resourceType = ObjectUtils.asString(options.get("resource_type"), "image"); String type = ObjectUtils.asString(options.get("type"), "upload"); Map params = new HashMap<String, Object>(); params.put("public_ids", publicIds); <BUG>return callApi(HttpMethod.POST, Arrays.asList("resources", resourceType, type, "restore"), params, options); }</BUG> public ApiResponse uploadMappings(Map options) throws Exception { if (options == null)
return callApi(HttpMethod.GET, Arrays.asList("folders"), ObjectUtils.emptyMap(), options); } public ApiResponse subFolders(String ofFolderPath, Map options) throws Exception {
467
this.queryLogger = Loggers.getLogger(logger, ".query"); this.fetchLogger = Loggers.getLogger(logger, ".fetch"); queryLogger.setLevel(level); fetchLogger.setLevel(level); indexSettingsService.addListener(new ApplySettings()); <BUG>} private long parseTimeSetting(String name, long defaultNanos) { try { return componentSettings.getAsTime(name, TimeValue.timeValueNanos(defaultNanos)).nanos(); } catch (ElasticSearchParseException e) { logger.error("Could not parse setting for [{}], disabling", name); return -1; }</BUG> }
[DELETED]
468
if (filters.isEmpty()) { return null; } BooleanQuery query = new BooleanQuery(); for (QueryBuilder f : filters) { <BUG>query.add(f.toQuery(parseContext), Occur.MUST); }</BUG> if (queryName != null) { parseContext.addNamedQuery(queryName, query); }
Query innerQuery = f.toQuery(parseContext); if (innerQuery != null) { query.add(innerQuery, Occur.MUST);
469
if (filters.isEmpty()) { return null; } BooleanQuery query = new BooleanQuery(); for (QueryBuilder f : filters) { <BUG>query.add(f.toQuery(parseContext), Occur.SHOULD); }</BUG> if (queryName != null) { parseContext.addNamedQuery(queryName, query); }
Query innerQuery = f.toQuery(parseContext); if (innerQuery != null) { query.add(innerQuery, Occur.SHOULD);
470
if (queryBuilder.filters().isEmpty()) { return null; } BooleanQuery query = new BooleanQuery(); for (QueryBuilder subQuery : queryBuilder.filters()) { <BUG>query.add(subQuery.toQuery(context), Occur.MUST); }</BUG> return query; } @Override
Query innerQuery = subQuery.toQuery(context); if (innerQuery != null) { query.add(innerQuery, Occur.MUST);
471
if (queryBuilder.filters().isEmpty()) { return null; } BooleanQuery query = new BooleanQuery(); for (QueryBuilder subQuery : queryBuilder.filters()) { <BUG>query.add(subQuery.toQuery(context), Occur.SHOULD); }</BUG> return query; } @Override
Query innerQuery = subQuery.toQuery(context); if (innerQuery != null) { query.add(innerQuery, Occur.SHOULD);
472
import static org.junit.Assert.assertTrue; public class ProxyServletTest { private LocalTestServer localTestServer; private ServletRunner servletRunner; <BUG>private ServletUnitClient sc; @Before</BUG> public void setUp() throws Exception { localTestServer = new LocalTestServer(null, null); localTestServer.start();
private String targetBaseUri; private String sourceBaseUri; @Before
473
} private static String[] testUrlSuffixes = new String[]{"","/pathInfo","?def=DEF","/pathInfo?def=DEF"}; @Test public void testGet() throws Exception { for (String urlSuffix : testUrlSuffixes) { <BUG>execGetAndAssert(makeGetMethodRequest("http://localhost/proxyMe"+urlSuffix)); </BUG> } } @Test
@After public void tearDown() throws Exception { servletRunner.shutDown(); localTestServer.stop(); execGetAndAssert(makeGetMethodRequest(sourceBaseUri +urlSuffix));
474
@Override protected void service(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException { InputStream is = servletRequest.getInputStream(); try { BasicHttpEntityEnclosingRequest proxyRequest = new BasicHttpEntityEnclosingRequest(servletRequest.getMethod(),getProxyURL(servletRequest)); <BUG>copyRequestHeaders(proxyRequest, servletRequest); proxyRequest.setEntity(new InputStreamEntity(is, servletRequest.getContentLength())); this.executeProxyRequest(proxyRequest,servletRequest,servletResponse); </BUG> } finally {
public void destroy() { proxyClient.getConnectionManager().shutdown(); super.destroy(); } copyRequestHeaders(servletRequest, proxyRequest); this.executeProxyRequest(proxyRequest, servletRequest, servletResponse);
475
package com.example.mapdemo; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.OnMapReadyCallback; <BUG>import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.Polygon;</BUG> import com.google.android.gms.maps.model.PolygonOptions; import android.graphics.Color;
import com.google.android.gms.maps.model.Dash; import com.google.android.gms.maps.model.Dot; import com.google.android.gms.maps.model.Gap; import com.google.android.gms.maps.model.JointType; import com.google.android.gms.maps.model.PatternItem; import com.google.android.gms.maps.model.Polygon;
476
this.queryLogger = Loggers.getLogger(logger, ".query"); this.fetchLogger = Loggers.getLogger(logger, ".fetch"); queryLogger.setLevel(level); fetchLogger.setLevel(level); indexSettingsService.addListener(new ApplySettings()); <BUG>} private long parseTimeSetting(String name, long defaultNanos) { try { return componentSettings.getAsTime(name, TimeValue.timeValueNanos(defaultNanos)).nanos(); } catch (ElasticSearchParseException e) { logger.error("Could not parse setting for [{}], disabling", name); return -1; }</BUG> }
[DELETED]
477
CHEVRON_RIGHT ("chevron-right", "png", false, false), CHEVRON_LEFT ("chevron-left", "png", false, false), SEARCH ("search", "png", false, false), CONTROL_SLIDER_BALL ("control-sliderball", "png", false, false), CONTROL_CHECK_ON ("control-check-on", "png", false, false), <BUG>CONTROL_CHECK_OFF ("control-check-off", "png", false, false), ALPHA_MAP ("alpha", "png", false, false);</BUG> private static final byte IMG_PNG = 1, IMG_JPG = 2;
USER ("user", "user%d", "png", false, false), ALPHA_MAP ("alpha", "png", false, false);
478
GameImage(String filename, String type, boolean beatmapSkinnable, boolean preload) { this.filename = filename; this.type = getType(type); this.beatmapSkinnable = beatmapSkinnable; this.preload = preload; <BUG>} public boolean isBeatmapSkinnable() { return beatmapSkinnable; }</BUG> public boolean isPreload() { return preload; } public Image getImage() { setDefaultImage();
GameImage(String filename, String filenameFormat, String type, boolean beatmapSkinnable, boolean preload) { this(filename, type, beatmapSkinnable, preload); this.filenameFormat = filenameFormat; public boolean isBeatmapSkinnable() { return beatmapSkinnable; }
479
g.drawRect(0, yPos, rectWidth, rectHeight); g.setLineWidth(oldLineWidth); data.drawSymbolString(rankString, rectWidth, yPos, 1.0f, alpha * 0.2f, true); white.a = blue.a = alpha * 0.75f; if (playerName != null) <BUG>Fonts.MEDIUMBOLD.drawString(xPaddingLeft, yPos + yPadding, playerName, white); Fonts.DEFAULT.drawString(</BUG> xPaddingLeft, yPos + rectHeight - Fonts.DEFAULT.getLineHeight() - yPadding, scoreString, white ); Fonts.DEFAULT.drawString(
Fonts.MEDIUM.drawString(xPaddingLeft, yPos + yPadding, playerName, white);
480
int objectCount = hit300 + hit100 + hit50 + miss; if (objectCount > 0) percent = (hit300 * 300 + hit100 * 100 + hit50 * 50) / (objectCount * 300f) * 100f; return percent; } <BUG>private float getScorePercent() { </BUG> return getScorePercent( hitResultCount[HIT_300], hitResultCount[HIT_100], hitResultCount[HIT_50], hitResultCount[HIT_MISS]
public float getScorePercent() {
481
sd.score = slidingScore ? scoreDisplay : score; sd.combo = comboMax; sd.perfect = (comboMax == fullObjectCount); sd.mods = GameMod.getModState(); sd.replayString = (replay == null) ? null : replay.getReplayFilename(); <BUG>sd.playerName = null; // TODO return sd;</BUG> } public Replay getReplay(ReplayFrame[] frames, Beatmap beatmap) { if (replay != null && frames == null)
sd.playerName = GameMod.AUTO.isActive() ? UserList.AUTO_USER_NAME : UserList.get().getCurrentUser().getName(); return sd;
482
return null; replay = new Replay(); replay.mode = Beatmap.MODE_OSU; replay.version = Updater.get().getBuildDate(); replay.beatmapHash = (beatmap == null) ? "" : beatmap.md5Hash; <BUG>replay.playerName = ""; // TODO replay.replayHash = Long.toString(System.currentTimeMillis()); // TODO</BUG> replay.hit300 = (short) hitResultCount[HIT_300]; replay.hit100 = (short) hitResultCount[HIT_100]; replay.hit50 = (short) hitResultCount[HIT_50];
replay.playerName = UserList.get().getCurrentUser().getName(); replay.replayHash = Long.toString(System.currentTimeMillis()); // TODO
483
import itdelatrisu.opsu.downloads.Download; import itdelatrisu.opsu.downloads.DownloadNode; import itdelatrisu.opsu.replay.PlaybackSpeed; import itdelatrisu.opsu.ui.Colors; import itdelatrisu.opsu.ui.Fonts; <BUG>import itdelatrisu.opsu.ui.UI; import java.awt.image.BufferedImage;</BUG> import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.File;
import itdelatrisu.opsu.user.UserButton; import itdelatrisu.opsu.user.UserList; import java.awt.image.BufferedImage;
484
else if (t == ANY_CYPHER_OPTION) { r = AnyCypherOption(b, 0); } else if (t == ANY_FUNCTION_INVOCATION) { r = AnyFunctionInvocation(b, 0); <BUG>} else if (t == BULK_IMPORT_QUERY) {</BUG> r = BulkImportQuery(b, 0); } else if (t == CALL) {
else if (t == ARRAY) { r = Array(b, 0); else if (t == BULK_IMPORT_QUERY) {
485
if (!r) r = MapLiteral(b, l + 1); if (!r) r = MapProjection(b, l + 1); if (!r) r = CountStar(b, l + 1); if (!r) r = ListComprehension(b, l + 1); if (!r) r = PatternComprehension(b, l + 1); <BUG>if (!r) r = Expression1_12(b, l + 1); if (!r) r = FilterFunctionInvocation(b, l + 1);</BUG> if (!r) r = ExtractFunctionInvocation(b, l + 1); if (!r) r = ReduceFunctionInvocation(b, l + 1); if (!r) r = AllFunctionInvocation(b, l + 1);
if (!r) r = Array(b, l + 1); if (!r) r = FilterFunctionInvocation(b, l + 1);
486
} @RootTask static Task<Exec.Result> exec(String parameter, int number) { Task<String> task1 = MyTask.create(parameter); Task<Integer> task2 = Adder.create(number, number + 2); <BUG>return Task.ofType(Exec.Result.class).named("exec", "/bin/sh") .in(() -> task1)</BUG> .in(() -> task2) .process(Exec.exec((str, i) -> args("/bin/sh", "-c", "\"echo " + i + "\""))); }
return Task.named("exec", "/bin/sh").ofType(Exec.Result.class) .in(() -> task1)
487
return args; } static class MyTask { static final int PLUS = 10; static Task<String> create(String parameter) { <BUG>return Task.ofType(String.class).named("MyTask", parameter) .in(() -> Adder.create(parameter.length(), PLUS))</BUG> .in(() -> Fib.create(parameter.length())) .process((sum, fib) -> something(parameter, sum, fib)); }
return Task.named("MyTask", parameter).ofType(String.class) .in(() -> Adder.create(parameter.length(), PLUS))
488
} @RootTask public static Task<String> standardArgs(int first, String second) { firstInt = first; secondString = second; <BUG>return Task.ofType(String.class).named("StandardArgs", first, second) .process(() -> second + " " + first * 100);</BUG> } @Test public void shouldParseFlags() throws Exception {
return Task.named("StandardArgs", first, second).ofType(String.class) .process(() -> second + " " + first * 100);
489
assertThat(parsedEnum, is(CustomEnum.BAR)); } @RootTask public static Task<String> enums(CustomEnum enm) { parsedEnum = enm; <BUG>return Task.ofType(String.class).named("Enums", enm) .process(enm::toString);</BUG> } @Test public void shouldParseCustomTypes() throws Exception {
return Task.named("Enums", enm).ofType(String.class) .process(enm::toString);
490
assertThat(parsedType.content, is("blarg parsed for you!")); } @RootTask public static Task<String> customType(CustomType myType) { parsedType = myType; <BUG>return Task.ofType(String.class).named("Types", myType.content) .process(() -> myType.content);</BUG> } public enum CustomEnum { BAR
return Task.named("Types", myType.content).ofType(String.class) .process(() -> myType.content);
491
TaskContext taskContext = TaskContext.inmem(); TaskContext.Value<Long> value = taskContext.evaluate(fib92); value.consume(f92 -> System.out.println("fib(92) = " + f92)); } static Task<Long> create(long n) { <BUG>TaskBuilder<Long> fib = Task.ofType(Long.class).named("Fib", n); </BUG> if (n < 2) { return fib .process(() -> n);
TaskBuilder<Long> fib = Task.named("Fib", n).ofType(Long.class);
492
customTokens.put("%%mlFinalForestsPerHost%%", hubConfig.finalForestsPerHost.toString()); customTokens.put("%%mlTraceAppserverName%%", hubConfig.traceHttpName); customTokens.put("%%mlTracePort%%", hubConfig.tracePort.toString()); customTokens.put("%%mlTraceDbName%%", hubConfig.traceDbName); customTokens.put("%%mlTraceForestsPerHost%%", hubConfig.traceForestsPerHost.toString()); <BUG>customTokens.put("%%mlModulesDbName%%", hubConfig.modulesDbName); }</BUG> public void init() { try { LOGGER.error("PLUGINS DIR: " + pluginsDir.toString());
customTokens.put("%%mlTriggersDbName%%", hubConfig.triggersDbName); customTokens.put("%%mlSchemasDbName%%", hubConfig.schemasDbName); }
493
public static final int TYPE_STRING_ARRAY = 26; public static final int TYPE_EXTERNALIABLE = 1000; public static Object invokeWebserviceSync(WSDefinition def, Object... arguments) throws IOException { WSConnection cr = new WSConnection(def, null, arguments); NetworkManager.getInstance().addToQueueAndWait(cr); <BUG>if(cr.getResponseCode() != 200) { throw new IOException("Server error: " + cr.getResponseCode());</BUG> } return cr.returnValue; }
int rc = cr.getResponseCode(); if(rc != 200 && rc != 201) { throw new IOException("Server error: " + cr.getResponseCode());
494
NetworkManager.getInstance().addToQueueAndWait(cr); d.dispose(); } else { NetworkManager.getInstance().addToQueueAndWait(cr); } <BUG>return cr.getResponseCode() == 200; }</BUG> public static void sleep(int t) { try { Thread.sleep(t);
int rc = cr.getResponseCode(); return rc == 200 || rc == 201;
495
import org.springframework.web.bind.annotation.RequestMethod; @Controller @RequestMapping("/content") public class MainContentController { private final Logger logger = Logger.getLogger(getClass()); <BUG>@Autowired private ContentCreationEventDao contentCreationEventDao;</BUG> @RequestMapping(method = RequestMethod.GET) public String handleRequest( HttpServletRequest request,
[DELETED]
496
@RequestMapping("/content/allophone/create") public class AllophoneCreateController { private final Logger logger = Logger.getLogger(getClass()); @Autowired private AllophoneDao allophoneDao; <BUG>@Autowired private ContentCreationEventDao contentCreationEventDao;</BUG> @Autowired private MessageSource messageSource; @RequestMapping(method = RequestMethod.GET)
[DELETED]
497
@RequestMapping("/content/allophone/edit") public class AllophoneEditController { private final Logger logger = Logger.getLogger(getClass()); @Autowired private AllophoneDao allophoneDao; <BUG>@Autowired private ContentCreationEventDao contentCreationEventDao;</BUG> @RequestMapping(value = "/{id}", method = RequestMethod.GET) public String handleRequest(Model model, @PathVariable Long id) { logger.info("handleRequest");
[DELETED]
498
package org.literacyapp.model.contributor; import java.util.Calendar; <BUG>import javax.persistence.Entity; import javax.persistence.ManyToOne; import javax.persistence.Temporal;</BUG> import javax.persistence.TemporalType; import javax.validation.constraints.NotNull;
import javax.persistence.MappedSuperclass; import javax.persistence.Temporal;
499
import javax.persistence.Temporal;</BUG> import javax.persistence.TemporalType; import javax.validation.constraints.NotNull; import org.literacyapp.model.BaseEntity; import org.literacyapp.model.Contributor; <BUG>@Entity public class ContributorEvent extends BaseEntity { </BUG> @NotNull @ManyToOne
package org.literacyapp.model.contributor; import java.util.Calendar; import javax.persistence.ManyToOne; import javax.persistence.MappedSuperclass; import javax.persistence.Temporal; @MappedSuperclass public abstract class ContributorEvent extends BaseEntity {
500
localConstants.add(fullName); writer.write(name(constant) + " = constant " + typeLiteral((ShadowValue)result)); } catch(ShadowException e) { <BUG>String message = BaseChecker.makeMessage(null, "Could not initialize constant " + name + ": " + e.getMessage(), node.getFile(), node.getLineStart(), node.getLineEnd(), node.getColumnStart(), node.getColumnEnd() ); </BUG> throw new ShadowException(message); } Cleanup.getInstance().walk(constant);
String message = TypeCheckException.makeMessage(null, "Could not initialize constant " + name + ": " + e.getMessage(), node.getFile(), node.getLineStart(), node.getLineEnd(), node.getColumnStart(), node.getColumnEnd() );