input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
@Override
public boolean isEquivalentTo(JSType otherType) {
if (!(otherType instanceof FunctionType)) {
return false;
}
FunctionType that = (FunctionType) otherType;
if (!that.isFunctionType()) {
return false;
}
if (this.isConstructor... | #fixed code
@Override
public boolean isEquivalentTo(JSType otherType) {
FunctionType that =
JSType.toMaybeFunctionType(otherType.toMaybeFunctionType());
if (that == null) {
return false;
}
if (this.isConstructor()) {
if (that.isConstructor()) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<JSSourceFile> getDefaultExterns() {
try {
InputStream input = Compiler.class.getResourceAsStream(
"/externs.zip");
ZipInputStream zip = new ZipInputStream(input);
List<JSSourceFile> externs = Lists.newLinkedList();
for (... | #fixed code
private List<JSSourceFile> getDefaultExterns() {
try {
return CommandLineRunner.getDefaultExterns();
} catch (IOException e) {
throw new BuildException(e);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Symbol getSymbolDeclaredBy(FunctionType fn) {
Preconditions.checkState(fn.isConstructor() || fn.isInterface());
ObjectType instanceType = fn.getInstanceType();
String name = instanceType.getReferenceName();
if (name == null || globalScope == null) {... | #fixed code
public Symbol getSymbolDeclaredBy(FunctionType fn) {
Preconditions.checkState(fn.isConstructor() || fn.isInterface());
ObjectType instanceType = fn.getInstanceType();
return getSymbolForName(fn.getSource(), instanceType.getReferenceName());
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void toDebugString(StringBuilder builder, Symbol symbol) {
SymbolScope scope = symbol.scope;
if (scope.isGlobalScope()) {
builder.append(
String.format("'%s' : in global scope:\n", symbol.getName()));
} else {
builder.append(
... | #fixed code
private void toDebugString(StringBuilder builder, Symbol symbol) {
SymbolScope scope = symbol.scope;
if (scope.isGlobalScope()) {
builder.append(
String.format("'%s' : in global scope:\n", symbol.getName()));
} else if (scope.getRootNode() != null) {... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void setSqlSource(MappedStatement ms) {
MapperTemplate mapperTemplate = getMapperTemplate(ms.getId());
try {
mapperTemplate.setSqlSource(ms);
} catch (Exception e) {
throw new RuntimeException("调用方法异常:" + e.getMessa... | #fixed code
public void setSqlSource(MappedStatement ms) {
MapperTemplate mapperTemplate = getMapperTemplate(ms.getId());
try {
if (mapperTemplate != null) {
mapperTemplate.setSqlSource(ms);
}
} catch (Exception e) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected String read(InputStream inputStream) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
StringBuffer stringBuffer = new StringBuffer();
String line = reader.readLine();
while (li... | #fixed code
protected String read(InputStream inputStream) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, encoding));
StringBuffer stringBuffer = new StringBuffer();
String line = reader.readLine();
while... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) {
@SuppressWarnings("resource")
ApplicationContext context = new ClassPathXmlApplicationContext("exampleContext.xml");
SpringCacheExample example = context.getBean(SpringCacheExample.class);
example.getBook(0);
example.getBo... | #fixed code
public static void main(String[] args) {
example();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) {
Cache<Integer, Integer> cache = CacheBuilder.transactionalHeapCache()
.transactionCommitter(new TransactionCommitter<Integer, Integer>() {
int counter = 0;
public void doPut(Integer key, Integer value) {
if (c... | #fixed code
public static void main(String[] args) {
example();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) {
@SuppressWarnings({ "resource", "unused" })
ApplicationContext context = new ClassPathXmlApplicationContext("exampleContext.xml");
}
#location 3
#vulnerability type RESO... | #fixed code
public static void main(String[] args) {
example();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) {
Cache<Integer, Integer> cache = CacheBuilder.transactionalHeapCache()
.transactionCommitter(new TransactionCommitter<Integer, Integer>() {
int counter = 0;
public void doPut(Integer key, Integer value) {
if (c... | #fixed code
public static void main(String[] args) {
example();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
static void installDependencies(PrintStream logger, Launcher launcher,
AndroidSdk sdk, EmulatorConfig emuConfig) throws IOException, InterruptedException {
// Get AVD platform from emulator config
String platform = getPlatformForEmulator(laun... | #fixed code
static void installDependencies(PrintStream logger, Launcher launcher,
AndroidSdk sdk, EmulatorConfig emuConfig) throws IOException, InterruptedException {
// Get AVD platform from emulator config
String platform = getPlatformForEmulator(launcher, ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void writeAvdConfigFile(File homeDir, Map<String,String> values) throws FileNotFoundException {
StringBuilder sb = new StringBuilder();
for (String key : values.keySet()) {
sb.append(key);
sb.append("=");
sb.a... | #fixed code
private void writeAvdConfigFile(File homeDir, Map<String,String> values) throws IOException {
final File configFile = getAvdConfigFile(homeDir);
ConfigFileUtils.writeConfigFile(configFile, values);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testTargetName() {
assertEquals("Google Inc.:Google APIs:23", AndroidPlatform.valueOf("Google Inc.:Google APIs:23").getTargetName());
assertEquals("Google Inc.:Google APIs:24", AndroidPlatform.valueOf("Google Inc.:Google APIs:24").g... | #fixed code
@Test
public void testTargetName() {
assertEquals("Some:Addon:11", AndroidPlatform.valueOf("Some:Addon:11").getTargetName());
assertEquals("Google Inc.:Google APIs:23", AndroidPlatform.valueOf("Google Inc.:Google APIs:23").getTargetName());
assertE... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSystemImageName() {
assertEquals("sys-img-x86-android-23", AndroidPlatform.valueOf("Google Inc.:Google APIs:23").getSystemImageName("x86"));
assertEquals("sys-img-x86-android-24", AndroidPlatform.valueOf("Google Inc.:Google APIs... | #fixed code
@Test
public void testSystemImageName() {
assertEquals("sys-img-x86-android-23", AndroidPlatform.valueOf("android-23").getSystemImageName("x86"));
assertEquals("sys-img-x86-google_apis-23", AndroidPlatform.valueOf("Google Inc.:Google APIs:23").getSystemIma... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void determinesItemBSourceSetter() {
Target target = new Target();
target.setItemB( new ItemB() );
SourceWithItemB source = new SourceWithItemB();
GenericsHierarchyMapper.INSTANCE.intoSourceWithItemB( target, source );
... | #fixed code
@Test
public void determinesItemBSourceSetter() {
Target target = new Target();
target.setKeyOfAllBeings( new KeyOfAllBeings() );
Child source = new Child();
GenericsHierarchyMapper.INSTANCE.updateSourceWithKeyOfAllBeings( target, source ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean isIterableMapping() {
return getSingleSourceType().isIterableType() && resultType.isIterableType();
}
#location 2
#vulnerability type NULL_DEREFERENCE | #fixed code
public boolean isIterableMapping() {
return getSingleSourceParameter().getType().isIterableType() && getResultType().isIterableType();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Mapping getMapping(MappingPrism mapping) {
Type converterType = typeUtil.retrieveType( mapping.converter() );
return new Mapping(
mapping.source(),
mapping.target(),
converterType.getName().equals( "NoOpConverter" ) ? null : converterType
);
}
... | #fixed code
private Mapping getMapping(MappingPrism mapping) {
return new Mapping( mapping.source(), mapping.target() );
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<MappedProperty> getMappedProperties(ExecutableElement method, Map<String, Mapping> mappings) {
Element returnTypeElement = typeUtils.asElement( method.getReturnType() );
Element parameterElement = typeUtils.asElement( method.getParameters().... | #fixed code
private List<MappedProperty> getMappedProperties(ExecutableElement method, Map<String, Mapping> mappings) {
TypeElement returnTypeElement = (TypeElement) typeUtils.asElement( method.getReturnType() );
TypeElement parameterElement = (TypeElement) typeUtils.asEl... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public boolean process(
final Set<? extends TypeElement> annotations,
final RoundEnvironment roundEnvironment) {
for ( TypeElement oneAnnotation : annotations ) {
//Indicates that the annotation's type isn't on the class path of the compiled
//pr... | #fixed code
@Override
public boolean process(
final Set<? extends TypeElement> annotations,
final RoundEnvironment roundEnvironment) {
for ( TypeElement oneAnnotation : annotations ) {
//Indicates that the annotation's type isn't on the class path of the compiled
//project.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Mapper process(ProcessorContext context, TypeElement mapperTypeElement, Mapper mapper) {
String componentModel = MapperPrism.getInstanceOn( mapperTypeElement ).componentModel();
if ( !componentModel.equals( "cdi" ) ) {
r... | #fixed code
@Override
public Mapper process(ProcessorContext context, TypeElement mapperTypeElement, Mapper mapper) {
String componentModel = MapperPrism.getInstanceOn( mapperTypeElement ).componentModel();
String effectiveComponentModel = OptionsHelper.getEffectiveCo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<MappedProperty> getMappedProperties(ExecutableElement method, Map<String, Mapping> mappings) {
Element returnTypeElement = typeUtils.asElement( method.getReturnType() );
Element parameterElement = typeUtils.asElement( method.getParameters().... | #fixed code
private List<MappedProperty> getMappedProperties(ExecutableElement method, Map<String, Mapping> mappings) {
TypeElement returnTypeElement = (TypeElement) typeUtils.asElement( method.getReturnType() );
TypeElement parameterElement = (TypeElement) typeUtils.asEl... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<Method> retrieveMethods(TypeElement element, boolean implementationRequired) {
List<Method> methods = new ArrayList<Method>();
MapperPrism mapperPrism = implementationRequired ? MapperPrism.getInstanceOn( element ) : null;
//TODO E... | #fixed code
private List<Method> retrieveMethods(TypeElement element, boolean implementationRequired) {
List<Method> methods = new ArrayList<Method>();
MapperPrism mapperPrism = implementationRequired ? MapperPrism.getInstanceOn( element ) : null;
for ( Executab... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private PropertyMapping getPropertyMapping(List<MapperReference> mapperReferences, List<Method> methods,
Method method, Parameter parameter, ExecutableElement sourceAccessor,
E... | #fixed code
private PropertyMapping getPropertyMapping(List<MapperReference> mapperReferences, List<Method> methods,
Method method, Parameter parameter, ExecutableElement sourceAccessor,
Executa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean isMapMapping() {
return getSingleSourceType().isMapType() && resultType.isMapType();
}
#location 2
#vulnerability type NULL_DEREFERENCE | #fixed code
public boolean isMapMapping() {
return getSingleSourceParameter().getType().isMapType() && getResultType().isMapType();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void deleteDirectory(File path) {
if ( path.exists() ) {
File[] files = path.listFiles();
for ( int i = 0; i < files.length; i++ ) {
if ( files[i].isDirectory() ) {
deleteDirectory( files[i] );
... | #fixed code
private void deleteDirectory(File path) {
if ( path.exists() ) {
File[] files = path.listFiles();
for ( File file : files ) {
if ( file.isDirectory() ) {
deleteDirectory( file );
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<Method> retrieveMethods(TypeElement element, boolean mapperRequiresImplementation) {
List<Method> methods = new ArrayList<Method>();
MapperPrism mapperPrism = mapperRequiresImplementation ? MapperPrism.getInstanceOn( element ) : null;
... | #fixed code
private List<Method> retrieveMethods(TypeElement element, boolean mapperRequiresImplementation) {
List<Method> methods = new ArrayList<Method>();
for ( ExecutableElement executable : methodsIn( element.getEnclosedElements() ) ) {
Method method = g... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<MappedProperty> getMappedProperties(ExecutableElement method, Map<String, Mapping> mappings) {
TypeElement returnTypeElement = (TypeElement) typeUtils.asElement( method.getReturnType() );
TypeElement parameterElement = (TypeElement) typeUtil... | #fixed code
private List<MappedProperty> getMappedProperties(ExecutableElement method, Map<String, Mapping> mappings) {
TypeElement returnTypeElement = (TypeElement) typeUtils.asElement( method.getReturnType() );
TypeElement parameterElement = (TypeElement) typeUtils.asEl... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void determinesItemCSourceSetter() {
Target target = new Target();
target.setItemC( new ItemC() );
SourceWithItemC source = new SourceWithItemC();
GenericsHierarchyMapper.INSTANCE.intoSourceWithItemC( target, source );
... | #fixed code
@Test
public void determinesItemCSourceSetter() {
Target target = new Target();
target.setAnimalKey( new AnimalKey() );
Elephant source = new Elephant();
GenericsHierarchyMapper.INSTANCE.updateSourceWithAnimalKey( target, source );
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private MappingMethod getBeanMappingMethod(List<Method> methods, Method method,
ReportingPolicy unmappedTargetPolicy) {
List<PropertyMapping> propertyMappings = new ArrayList<PropertyMapping>();
Set<String> ... | #fixed code
private MappingMethod getBeanMappingMethod(List<Method> methods, Method method,
ReportingPolicy unmappedTargetPolicy) {
List<PropertyMapping> propertyMappings = new ArrayList<PropertyMapping>();
Set<String> mapped... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean matches() {
// check & collect generic types.
List<? extends VariableElement> candidateParameters = candidateMethod.getExecutable().getParameters();
if ( candidateParameters.size() == parameters.length ) {
for ( int i ... | #fixed code
public boolean matches() {
// check & collect generic types.
List<? extends VariableElement> candidateParameters = candidateMethod.getExecutable().getParameters();
if ( candidateParameters.size() != 1 ) {
typesMatch = false;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Mapper retrieveModel(TypeElement element) {
//1.) build up "source" model
List<Method> methods = retrieveMethods( element, true );
//2.) build up aggregated "target" model
List<BeanMapping> mappings = getMappings(
met... | #fixed code
private Mapper retrieveModel(TypeElement element) {
//1.) build up "source" model
List<Method> methods = retrieveMethods( element, true );
//2.) build up aggregated "target" model
List<BeanMapping> mappings = getMappings(
methods,
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<MappedProperty> getMappedProperties(ExecutableElement method, Map<String, Mapping> mappings) {
TypeElement returnTypeElement = (TypeElement) typeUtils.asElement( method.getReturnType() );
TypeElement parameterElement = (TypeElement) typeUtil... | #fixed code
private List<MappedProperty> getMappedProperties(ExecutableElement method, Map<String, Mapping> mappings) {
TypeElement returnTypeElement = (TypeElement) typeUtils.asElement( method.getReturnType() );
TypeElement parameterElement = (TypeElement) typeUtils.asEl... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private PropertyMapping getConstantMapping(List<MapperReference> mapperReferences,
List<SourceMethod> methods,
SourceMethod method,
... | #fixed code
private PropertyMapping getConstantMapping(List<MapperReference> mapperReferences,
List<SourceMethod> methods,
SourceMethod method,
Str... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void reportErrorIfPropertyCanNotBeMapped(Method method, PropertyMapping property) {
if ( property.getSourceType().equals( property.getTargetType() ) ||
property.getMappingMethod() != null ||
property.getConversion() != null ||
... | #fixed code
private void reportErrorIfPropertyCanNotBeMapped(Method method, PropertyMapping property) {
if ( property.getSourceType().isAssignableTo( property.getTargetType() ) ||
property.getMappingMethod() != null ||
property.getConversion() != null ||
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<MappedProperty> getMappedProperties(ExecutableElement method, Map<String, Mapping> mappings) {
TypeElement returnTypeElement = (TypeElement) typeUtils.asElement( method.getReturnType() );
TypeElement parameterElement = (TypeElement) typeUtil... | #fixed code
private List<MappedProperty> getMappedProperties(ExecutableElement method, Map<String, Mapping> mappings) {
TypeElement returnTypeElement = (TypeElement) typeUtils.asElement( method.getReturnType() );
TypeElement parameterElement = (TypeElement) typeUtils.asEl... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private PropertyMapping getPropertyMapping(List<MapperReference> mapperReferences,
List<SourceMethod> methods,
SourceMethod method,
... | #fixed code
private PropertyMapping getPropertyMapping(List<MapperReference> mapperReferences,
List<SourceMethod> methods,
SourceMethod method,
Par... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Type getType(TypeMirror mirror, boolean isLiteral) {
if ( !canBeProcessed( mirror ) ) {
throw new TypeHierarchyErroneousException( mirror );
}
ImplementationType implementationType = getImplementationType( mirror );
... | #fixed code
private Type getType(TypeMirror mirror, boolean isLiteral) {
if ( !canBeProcessed( mirror ) ) {
throw new TypeHierarchyErroneousException( mirror );
}
ImplementationType implementationType = getImplementationType( mirror );
boolea... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<MappedProperty> getMappedProperties(ExecutableElement method, Map<String, Mapping> mappings) {
Element returnTypeElement = typeUtils.asElement( method.getReturnType() );
Element parameterElement = typeUtils.asElement( method.getParameters().get( 0 ).asType... | #fixed code
private List<MappedProperty> getMappedProperties(ExecutableElement method, Map<String, Mapping> mappings) {
Element returnTypeElement = typeUtils.asElement( method.getReturnType() );
Element parameterElement = typeUtils.asElement( method.getParameters().get( 0 ).asType() );
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static Object getValue(final V8Array array, final int index, final V8Map<Object> cache) {
int valueType = array.getType(index);
switch (valueType) {
case V8Value.INTEGER:
return array.getInteger(index);
cas... | #fixed code
private static Object getValue(final V8Array array, final int index, final V8Map<Object> cache) {
int valueType = array.getType(index);
switch (valueType) {
case V8Value.INTEGER:
return array.getInteger(index);
case V8Va... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static V8 createV8Runtime(final String globalAlias, final String tempDirectory) {
if (!nativeLibraryLoaded) {
synchronized (lock) {
if (!nativeLibraryLoaded) {
load(tempDirectory);
}
... | #fixed code
public static V8 createV8Runtime(final String globalAlias, final String tempDirectory) {
if (!nativeLibraryLoaded) {
synchronized (lock) {
if (!nativeLibraryLoaded) {
load(tempDirectory);
}
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void release(final boolean reportMemoryLeaks) {
if (isReleased()) {
return;
}
checkThread();
if (debugEnabled) {
disableDebugSupport();
}
releaseResources();
shutdownExecutors(forceTe... | #fixed code
public void release(final boolean reportMemoryLeaks) {
if (isReleased()) {
return;
}
checkThread();
releaseResources();
shutdownExecutors(forceTerminateExecutors);
if (executors != null) {
executors.clear... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void release(final boolean reportMemoryLeaks) {
checkThread();
if (isReleased()) {
return;
}
if (debugEnabled) {
disableDebugSupport();
}
runtimeCounter--;
_releaseRuntime(v8RuntimePt... | #fixed code
public void release(final boolean reportMemoryLeaks) {
checkThread();
if (isReleased()) {
return;
}
if (debugEnabled) {
disableDebugSupport();
}
synchronized (lock) {
runtimeCounter--;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static Object getValue(final V8Object object, final String key, final V8Map<Object> cache) {
int valueType = object.getType(key);
switch (valueType) {
case V8Value.INTEGER:
return object.getInteger(key);
ca... | #fixed code
private static Object getValue(final V8Object object, final String key, final V8Map<Object> cache) {
int valueType = object.getType(key);
switch (valueType) {
case V8Value.INTEGER:
return object.getInteger(key);
case V8V... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static V8 createV8Runtime(final String globalAlias, final String tempDirectory) {
if (!nativeLibraryLoaded) {
synchronized (lock) {
if (!nativeLibraryLoaded) {
load(tempDirectory);
}
... | #fixed code
public static V8 createV8Runtime(final String globalAlias, final String tempDirectory) {
if (!nativeLibraryLoaded) {
synchronized (lock) {
if (!nativeLibraryLoaded) {
load(tempDirectory);
}
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static Object getValue(final V8Array array, final int index, final V8Map<Object> cache) {
int valueType = array.getType(index);
switch (valueType) {
case V8Value.INTEGER:
return array.getInteger(index);
cas... | #fixed code
private static Object getValue(final V8Array array, final int index, final V8Map<Object> cache) {
int valueType = array.getType(index);
switch (valueType) {
case V8Value.INTEGER:
return array.getInteger(index);
case V8Va... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void release(final boolean reportMemoryLeaks) {
if (isReleased()) {
return;
}
checkThread();
try {
notifyReleaseHandlers(this);
} finally {
releaseResources();
shutdownExecuto... | #fixed code
public void release(final boolean reportMemoryLeaks) {
if (isReleased()) {
return;
}
checkThread();
try {
notifyReleaseHandlers(this);
} finally {
releaseResources();
shutdownExecutors(for... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static Object getValue(final V8Array array, final int index, final V8Map<Object> cache) {
int valueType = array.getType(index);
switch (valueType) {
case V8Value.INTEGER:
return array.getInteger(index);
cas... | #fixed code
private static Object getValue(final V8Array array, final int index, final V8Map<Object> cache) {
int valueType = array.getType(index);
switch (valueType) {
case V8Value.INTEGER:
return array.getInteger(index);
case V8Va... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testTypedArrayGetValue_Float32Array() {
V8Array floatsArray = v8.executeArrayScript("var buf = new ArrayBuffer(100);\n"
+ "var floatsArray = new Float32Array(buf);\n"
+ "floatsArray[0] = 16.2;\n"
... | #fixed code
@Test
public void testTypedArrayGetValue_Float32Array() {
V8Array floatsArray = v8.executeArrayScript("var buf = new ArrayBuffer(100);\n"
+ "var floatsArray = new Float32Array(buf);\n"
+ "floatsArray[0] = 16.2;\n"
+ ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static Object getValue(final V8Object object, final String key, final V8Map<Object> cache) {
int valueType = object.getType(key);
switch (valueType) {
case V8Value.INTEGER:
return object.getInteger(key);
ca... | #fixed code
private static Object getValue(final V8Object object, final String key, final V8Map<Object> cache) {
int valueType = object.getType(key);
switch (valueType) {
case V8Value.INTEGER:
return object.getInteger(key);
case V8V... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void release(final boolean reportMemoryLeaks) {
if (isReleased()) {
return;
}
checkThread();
if (debugEnabled) {
disableDebugSupport();
}
releaseResources();
shutdownExecutors(forceTe... | #fixed code
public void release(final boolean reportMemoryLeaks) {
if (isReleased()) {
return;
}
checkThread();
releaseResources();
shutdownExecutors(forceTerminateExecutors);
if (executors != null) {
executors.clear... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testTypedArrayGetValue_Float64Array() {
V8Array floatsArray = v8.executeArrayScript("var buf = new ArrayBuffer(80);\n"
+ "var floatsArray = new Float64Array(buf);\n"
+ "floatsArray[0] = 16.2;\n"
... | #fixed code
@Test
public void testTypedArrayGetValue_Float64Array() {
V8Array floatsArray = v8.executeArrayScript("var buf = new ArrayBuffer(80);\n"
+ "var floatsArray = new Float64Array(buf);\n"
+ "floatsArray[0] = 16.2;\n"
+ "... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static Object getValue(final V8Object object, final String key, final V8Map<Object> cache) {
int valueType = object.getType(key);
switch (valueType) {
case V8Value.INTEGER:
return object.getInteger(key);
ca... | #fixed code
private static Object getValue(final V8Object object, final String key, final V8Map<Object> cache) {
int valueType = object.getType(key);
switch (valueType) {
case V8Value.INTEGER:
return object.getInteger(key);
case V8V... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean enableDebugSupport(final int port, final boolean waitForConnection) {
V8.checkDebugThread();
debugEnabled = enableDebugSupport(getHandle(), port, waitForConnection);
return debugEnabled;
}
#location... | #fixed code
public boolean enableDebugSupport(final int port, final boolean waitForConnection) {
V8.checkDebugThread();
debugEnabled = enableDebugSupport(getV8RuntimePtr(), port, waitForConnection);
return debugEnabled;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public CommandLine parse(final String[] args) throws ParseException, IllegalArgumentException {
final CommandLine cmd = super.parse(args);
final Report report = ReportFactory.createReport(cmd, ReportType.REDIS);
ExtractionResult match = null;
if (cmd.hasOption("r... | #fixed code
public CommandLine parse(final String[] args) throws ParseException, IllegalArgumentException {
final CommandLine cmd = super.parse(args);
final String[] files = cmd.getArgs();
if (files.length > 1) {
throw new IllegalArgumentException("Only one dump file path may be ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
@Override
public void run() {
// restart the clock.
lastResponseMs = clock.currentTimeMillis();
this.rowMerger = new RowMerger(rowObserver);
synchronized (callLock) {
super.run();
// pre-fetch one more result,... | #fixed code
@SuppressWarnings("unchecked")
@Override
public void run() {
// restart the clock.
this.rowMerger = new RowMerger(rowObserver);
adapter = new CallToStreamObserverAdapter();
synchronized (callLock) {
super.run();
// pre-fetch one more result, for ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
@Test
public void testMutation() throws IOException, InterruptedException {
final ReentrantLock lock = new ReentrantLock();
final Condition mutateRowAsyncCalled = lock.newCondition();
when(mockClient.mutateRowAsync(any(Mutate... | #fixed code
@SuppressWarnings("unchecked")
@Test
public void testMutation() throws IOException, InterruptedException {
when(mockClient.mutateRowAsync(any(MutateRowRequest.class)))
.thenReturn(mockFuture);
BigtableBufferedMutator underTest = createMutator(new Configurati... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Credentials getCredentialFromPrivateKeyServiceAccount(
String serviceAccountEmail, String privateKeyFile, List<String> scopes)
throws IOException, GeneralSecurityException {
PrivateKey privateKey =
SecurityUtils.loadPrivateKeyFromKey... | #fixed code
public static Credentials getCredentialFromPrivateKeyServiceAccount(
String serviceAccountEmail, String privateKeyFile, List<String> scopes)
throws IOException, GeneralSecurityException {
PrivateKey privateKey =
SecurityUtils.loadPrivateKeyFromKeyStore(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testRefresh() throws IOException {
Mockito.when(credentials.refreshAccessToken()).thenReturn(
new AccessToken("", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1)));
underTest = new RefreshingOAuth2CredentialsInterceptor(MoreExecutor... | #fixed code
@Test
public void testRefresh() throws IOException {
Mockito.when(mockCredentials.refreshAccessToken()).thenReturn(
new AccessToken("", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1)));
underTest = new RefreshingOAuth2CredentialsInterceptor(MoreExecutors.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
/**
* Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh
* logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it
* triggers a call to syncRefresh() which potentially waits for re... | #fixed code
@Test
/**
* Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh
* logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it
* triggers a call to syncRefresh() which potentially waits for refresh ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
/**
* Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh
* logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it
* triggers a call to syncRefresh() which potentially waits for re... | #fixed code
@Test
/**
* Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh
* logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it
* triggers a call to syncRefresh() which potentially waits for refresh ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCBC_UserAgentUsingPlainTextNegotiation() throws Exception{
ServerSocket serverSocket = new ServerSocket(0);
final int availablePort = serverSocket.getLocalPort();
serverSocket.close();
//Creates non-ssl server.
createServer(ava... | #fixed code
@Test
public void testCBC_UserAgentUsingPlainTextNegotiation() throws Exception{
ServerSocket serverSocket = new ServerSocket(0);
final int availablePort = serverSocket.getLocalPort();
serverSocket.close();
//Creates non-ssl server.
createServer(available... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
/**
* Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh
* logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it
* triggers a call to syncRefresh() which potentially waits for re... | #fixed code
@Test
/**
* Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh
* logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it
* triggers a call to syncRefresh() which potentially waits for refresh ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testRetyableCheckAndMutateRow() throws InterruptedException {
final CheckAndMutateRowRequest request = CheckAndMutateRowRequest.getDefaultInstance();
final AtomicBoolean done = new AtomicBoolean(false);
executor.submit(new Callable<Void>(){... | #fixed code
@Test
public void testRetyableCheckAndMutateRow() throws Exception {
final CheckAndMutateRowRequest request = CheckAndMutateRowRequest.getDefaultInstance();
when(mockFuture.get()).thenReturn(CheckAndMutateRowResponse.getDefaultInstance());
underTest.checkAndMutate... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testRefreshAfterStale() throws Exception {
underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials);
underTest.rateLimiter.setRate(100000);
final AccessToken staleToken = new AccessToken("stale", new Date(Header... | #fixed code
@Test
public void testRefreshAfterStale() throws Exception {
underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials);
final AccessToken staleToken = new AccessToken("stale", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1));
Access... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void run() {
try (Scope scope = TRACER.withSpan(operationSpan)) {
rpcTimerContext = rpc.getRpcMetrics().timeRpc();
operationSpan.addAnnotation(Annotation.fromDescriptionAndAttributes("rpcStart",
ImmutableMap.of("attempt", AttributeValue.l... | #fixed code
protected void run() {
try (Scope scope = TRACER.withSpan(operationSpan)) {
rpcTimerContext = rpc.getRpcMetrics().timeRpc();
operationSpan.addAnnotation(Annotation.fromDescriptionAndAttributes("rpcStart",
ImmutableMap.of("attempt", AttributeValue.longAtt... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testRefreshAfterStale() throws Exception {
underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials);
underTest.rateLimiter.setRate(100000);
final AccessToken staleToken = new AccessToken("stale", new Date(Header... | #fixed code
@Test
public void testRefreshAfterStale() throws Exception {
underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials);
final AccessToken staleToken = new AccessToken("stale", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1));
Access... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testPartialResults() throws Exception {
byte[] key1 = randomBytes(8);
byte[] key2 = randomBytes(8);
FlatRow response1 =
FlatRow.newBuilder()
.withRowKey(ByteString.copyFrom(key1))
.addCell(
ne... | #fixed code
@Test
public void testPartialResults() throws Exception {
byte[] key1 = randomBytes(8);
byte[] key2 = randomBytes(8);
FlatRow response1 =
FlatRow.newBuilder()
.withRowKey(ByteString.copyFrom(key1))
.addCell(
new Cell... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSyncRefresh() throws IOException {
initialize(HeaderCacheElement.TOKEN_STALENESS_MS + 1);
Assert.assertEquals(CacheState.Good, underTest.headerCache.getCacheState());
Assert.assertFalse(underTest.isRefreshing());
}
... | #fixed code
@Test
public void testSyncRefresh() throws IOException {
Mockito.when(mockCredentials.refreshAccessToken()).thenReturn(
new AccessToken("", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1)));
underTest = new RefreshingOAuth2CredentialsInterceptor(executorSe... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
/*
* Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh
* logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it
* triggers a call to syncRefresh() which potentially waits for refr... | #fixed code
@Test
/*
* Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh
* logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it
* triggers a call to syncRefresh() which potentially waits for refresh th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void flush() throws IOException {
// If there is a bulk mutation in progress, then send it.
if (bulkMutation != null) {
try {
bulkMutation.flush();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
th... | #fixed code
public void flush() throws IOException {
// If there is a bulk mutation in progress, then send it.
if (bulkMutation != null) {
try {
bulkMutation.flush();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw ne... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
/**
* Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh
* logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it
* triggers a call to syncRefresh() which potentially waits for re... | #fixed code
@Test
/**
* Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh
* logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it
* triggers a call to syncRefresh() which potentially waits for refresh ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testStaleAndExpired() throws IOException {
long expiration = HeaderCacheElement.TOKEN_STALENESS_MS + 1;
initialize(expiration);
Assert.assertEquals(CacheState.Good, underTest.headerCache.getCacheState());
long startTime = 2L;
setTim... | #fixed code
@Test
public void testStaleAndExpired() throws IOException {
long expiration = HeaderCacheElement.TOKEN_STALENESS_MS + 1;
initialize(expiration);
Assert.assertEquals(CacheState.Good, underTest.getCacheState());
long startTime = 2L;
setTimeInMillieconds(sta... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testOptionsAreConstructedWithValidInput() throws IOException {
configuration.set(BigtableOptionsFactory.BIGTABLE_HOST_KEY, TEST_HOST);
configuration.setBoolean(BigtableOptionsFactory.BIGTABLE_USE_SERVICE_ACCOUNTS_KEY, false);
configuration.... | #fixed code
@Test
public void testOptionsAreConstructedWithValidInput() throws IOException {
configuration.set(BigtableOptionsFactory.BIGTABLE_HOST_KEY, TEST_HOST);
configuration.setBoolean(BigtableOptionsFactory.BIGTABLE_USE_SERVICE_ACCOUNTS_KEY, false);
configuration.setBoo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testRetyableCheckAndMutateRow() throws InterruptedException {
final CheckAndMutateRowRequest request = CheckAndMutateRowRequest.getDefaultInstance();
final AtomicBoolean done = new AtomicBoolean(false);
executor.submit(new Callable<Void>(){... | #fixed code
@Test
public void testRetyableCheckAndMutateRow() throws Exception {
final CheckAndMutateRowRequest request = CheckAndMutateRowRequest.getDefaultInstance();
when(mockFuture.get()).thenReturn(CheckAndMutateRowResponse.getDefaultInstance());
underTest.checkAndMutate... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void onClose(Status status, Metadata trailers) {
if (status.getCode() == Status.Code.CANCELLED
&& status.getDescription().contains(TIMEOUT_CANCEL_MSG)) {
// If this was canceled because of handleTimeout(). The cancel is immediately ret... | #fixed code
@Override
public void onClose(Status status, Metadata trailers) {
if (status.getCode() == Status.Code.CANCELLED
&& status.getDescription() != null
&& status.getDescription().contains(TIMEOUT_CANCEL_MSG)) {
// If this was canceled because of handleTim... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
/*
* Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh
* logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it
* triggers a call to syncRefresh() which potentially waits for refr... | #fixed code
@Test
/*
* Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh
* logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it
* triggers a call to syncRefresh() which potentially waits for refresh th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testMutateRowPredicate() {
Predicate<MutateRowRequest> predicate = BigtableDataGrpcClient.IS_RETRYABLE_MUTATION;
assertFalse(predicate.apply(null));
MutateRowRequest.Builder request = MutateRowRequest.newBuilder();
assertTrue(predicate... | #fixed code
@Test
public void testMutateRowPredicate() {
Predicate<MutateRowRequest> defaultPredicate = BigtableDataGrpcClient.IS_RETRYABLE_MUTATION;
createClient(true);
Predicate<MutateRowRequest> allowNoTimestampsPredicate =
predicates.get(BigtableServiceGrpc.METHOD... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
/*
* Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh
* logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it
* triggers a call to syncRefresh() which potentially waits for refr... | #fixed code
@Test
/*
* Test that checks that concurrent requests to RefreshingOAuth2CredentialsInterceptor refresh
* logic doesn't cause hanging behavior. Specifically, when an Expired condition occurs it
* triggers a call to syncRefresh() which potentially waits for refresh th... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSyncRefresh() throws IOException {
initialize(HeaderCacheElement.TOKEN_STALENESS_MS + 1);
Assert.assertEquals(CacheState.Good, underTest.headerCache.getCacheState());
}
#location 4
... | #fixed code
@Test
public void testSyncRefresh() throws IOException {
initialize(HeaderCacheElement.TOKEN_STALENESS_MS + 1);
Assert.assertEquals(CacheState.Good, underTest.headerCache.getCacheState());
Assert.assertFalse(underTest.isRefreshing());
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSyncRefresh() throws IOException {
initialize(HeaderCacheElement.TOKEN_STALENESS_MS + 1);
Assert.assertEquals(CacheState.Good, underTest.headerCache.getCacheState());
}
#location 3
... | #fixed code
@Test
public void testSyncRefresh() throws IOException {
initialize(HeaderCacheElement.TOKEN_STALENESS_MS + 1);
Assert.assertEquals(CacheState.Good, underTest.headerCache.getCacheState());
Assert.assertFalse(underTest.isRefreshing());
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testBatchBulkGets() throws Exception {
final List<Get> gets = new ArrayList<>(10);
final List<ApiFuture<FlatRow>> expected = new ArrayList<>(10);
gets.add(new Get(Bytes.toBytes("key0")));
expected.add(ApiFutures.<FlatRow>immediateFutur... | #fixed code
@Test
public void testBatchBulkGets() throws Exception {
final List<Get> gets = new ArrayList<>(10);
final List<ApiFuture<FlatRow>> expected = new ArrayList<>(10);
gets.add(new Get(Bytes.toBytes("key0")));
expected.add(ApiFutures.<FlatRow>immediateFuture(null... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void setMessageCompression(boolean enable) {
call.setMessageCompression(enable);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
public void setMessageCompression(boolean enable) {
throw new UnsupportedOperationException("setMessageCompression()");
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void modifyTable(TableName tableName, TableDescriptor tableDescriptor) throws IOException {
if (isTableAvailable(tableName)) {
TableDescriptor currentTableDescriptor = getTableDescriptor(tableName);
List<Modification> modifications = new... | #fixed code
@Override
public void modifyTable(TableName tableName, TableDescriptor tableDescriptor) throws IOException {
super.modifyTable(tableName, new HTableDescriptor(tableDescriptor));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void onClose(Status status, Metadata trailers) {
synchronized (callLock) {
call = null;
}
rpcTimerContext.close();
Status.Code code = status.getCode();
// OK
if (code == Status.Code.OK) {
if (onOK()) {
opera... | #fixed code
@Override
public void onClose(Status status, Metadata trailers) {
synchronized (callLock) {
call = null;
}
rpcTimerContext.close();
// OK
if (status.isOk()) {
if (onOK(trailers)) {
operationTimerContext.close();
}
} else {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testChannelsAreRoundRobinned() throws IOException {
MockChannelFactory factory = new MockChannelFactory();
MethodDescriptor descriptor = mock(MethodDescriptor.class);
MockitoAnnotations.initMocks(this);
ChannelPool pool = new ChannelPoo... | #fixed code
@Test
public void testChannelsAreRoundRobinned() throws IOException {
MockChannelFactory factory = new MockChannelFactory();
MethodDescriptor descriptor = mock(MethodDescriptor.class);
MockitoAnnotations.initMocks(this);
ChannelPool pool = new ChannelPool(null... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testRefreshAfterFailure() throws Exception {
underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials);
underTest.rateLimiter.setRate(100000);
final AccessToken accessToken = new AccessToken("hi", new Date(Header... | #fixed code
@Test
public void testRefreshAfterFailure() throws Exception {
underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials);
final AccessToken accessToken = new AccessToken("hi", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1));
//noi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCBC_UserAgentUsingPlainTextNegotiation() throws Exception{
ServerSocket serverSocket = new ServerSocket(0);
final int availablePort = serverSocket.getLocalPort();
serverSocket.close();
//Creates non-ssl server.
createServer(ava... | #fixed code
@Test
public void testCBC_UserAgentUsingPlainTextNegotiation() throws Exception{
ServerSocket serverSocket = new ServerSocket(0);
final int availablePort = serverSocket.getLocalPort();
serverSocket.close();
//Creates non-ssl server.
createServer(available... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
@Override
public void run() {
try {
// restart the clock.
this.rowMerger = new RowMerger(rowObserver);
adapter = new CallToStreamObserverAdapter();
synchronized (callLock) {
super.run();
// pre... | #fixed code
@SuppressWarnings("unchecked")
@Override
public void run() {
try {
// restart the clock.
synchronized (callLock) {
super.run();
// pre-fetch one more result, for performance reasons.
adapter.request(1);
if (rowObserver instanc... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void retryOnTimeout(ScanTimeoutException rte) throws BigtableRetriesExhaustedException {
LOG.info("The client could not get a response in %d ms. Retrying the scan.",
retryOptions.getReadPartialRowTimeoutMillis());
// Cancel the existing rpc.
can... | #fixed code
private void retryOnTimeout(ScanTimeoutException rte) throws BigtableRetriesExhaustedException {
LOG.info("The client could not get a response in %d ms. Retrying the scan.",
retryOptions.getReadPartialRowTimeoutMillis());
// Cancel the existing rpc.
cancel(TI... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void onClose(Status status, Metadata trailers) {
try (Scope scope = TRACER.withSpan(operationSpan)) {
synchronized (callLock) {
call = NULL_CALL;
}
rpcTimerContext.close();
// OK
if (status.isOk()) {
if ... | #fixed code
@Override
public void onClose(Status status, Metadata trailers) {
try (Scope scope = TRACER.withSpan(operationSpan)) {
callWrapper.resetCall();
rpcTimerContext.close();
// OK
if (status.isOk()) {
if (onOK(trailers)) {
finalizeStat... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Credentials getCredentials(CredentialOptions options)
throws IOException, GeneralSecurityException {
switch (options.getCredentialType()) {
case DefaultCredentials:
return getApplicationDefaultCredential();
case P12:
P12... | #fixed code
public static Credentials getCredentials(CredentialOptions options)
throws IOException, GeneralSecurityException {
return patchCredentials(getCredentialsInner(options));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void awaitCompletion() throws InterruptedException {
boolean performedWarning = false;
lock.lock();
try {
while (!isFlushed()) {
flushedCondition.await(finishWaitMillis, TimeUnit.MILLISECONDS);
long now = clock.nanoTime();
... | #fixed code
public void awaitCompletion() throws InterruptedException {
boolean performedWarning = false;
lock.lock();
try {
while (!isFlushed()) {
flushedCondition.await(finishWaitMillis, TimeUnit.MILLISECONDS);
long now = clock.nanoTime();
if (... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testRefreshAfterStale() throws Exception {
underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials);
underTest.rateLimiter.setRate(100000);
final AccessToken staleToken = new AccessToken("stale", new Date(Header... | #fixed code
@Test
public void testRefreshAfterStale() throws Exception {
underTest = new RefreshingOAuth2CredentialsInterceptor(executorService, credentials);
final AccessToken staleToken = new AccessToken("stale", new Date(HeaderCacheElement.TOKEN_STALENESS_MS + 1));
Access... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
@Override
public void run() {
try {
// restart the clock.
this.rowMerger = new RowMerger(rowObserver);
adapter = new CallToStreamObserverAdapter();
synchronized (callLock) {
super.run();
// pre... | #fixed code
@SuppressWarnings("unchecked")
@Override
public void run() {
try {
// restart the clock.
synchronized (callLock) {
super.run();
// pre-fetch one more result, for performance reasons.
adapter.request(1);
if (rowObserver instanc... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testBatchBulkGets() throws Exception {
final List<Get> gets = new ArrayList<>(10);
final List<ApiFuture<FlatRow>> expected = new ArrayList<>(10);
gets.add(new Get(Bytes.toBytes("key0")));
expected.add(ApiFutures.<FlatRow>immediateFutur... | #fixed code
@Test
public void testBatchBulkGets() throws Exception {
final List<Get> gets = new ArrayList<>(10);
final List<ApiFuture<Result>> expected = new ArrayList<>(10);
gets.add(new Get(Bytes.toBytes("key0")));
expected.add(ApiFutures.<Result>immediateFuture(null))... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testPartialResults() throws Exception {
when(mockBigtableApi.getDataClient()).thenReturn(mockDataClientWrapper);
when(mockDataClientWrapper.createBulkRead(isA(String.class))).thenReturn(mockBulkRead);
byte[] key1 = randomBytes(8);
byte[... | #fixed code
@Test
public void testPartialResults() throws Exception {
when(mockBigtableApi.getDataClient()).thenReturn(mockDataClientWrapper);
when(mockDataClientWrapper.createBulkRead(isA(String.class))).thenReturn(mockBulkRead);
byte[] key1 = randomBytes(8);
byte[] key2... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void onClose(Status status, Metadata trailers) {
try (Scope scope = TRACER.withSpan(operationSpan)) {
synchronized (callLock) {
call = NULL_CALL;
}
rpcTimerContext.close();
// OK
if (status.isOk()) {
if ... | #fixed code
@Override
public void onClose(Status status, Metadata trailers) {
try (Scope scope = TRACER.withSpan(operationSpan)) {
callWrapper.resetCall();
rpcTimerContext.close();
// OK
if (status.isOk()) {
if (onOK(trailers)) {
finalizeStat... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCBC_UserAgentUsingPlainTextNegotiation() throws Exception{
ServerSocket serverSocket = new ServerSocket(0);
final int availablePort = serverSocket.getLocalPort();
serverSocket.close();
//Creates non-ssl server.
createServer(ava... | #fixed code
@Test
public void testCBC_UserAgentUsingPlainTextNegotiation() throws Exception{
ServerSocket serverSocket = new ServerSocket(0);
final int availablePort = serverSocket.getLocalPort();
serverSocket.close();
//Creates non-ssl server.
createServer(available... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Result[] batch(final List<? extends org.apache.hadoop.hbase.client.Row> actions)
throws Exception {
return createExecutor(options).batch(actions);
}
#location 3
#vulnerability type RESOURCE_LEAK | #fixed code
private Result[] batch(final List<? extends org.apache.hadoop.hbase.client.Row> actions)
throws Exception {
return createExecutor().batch(actions);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void onClose(Status status, Metadata trailers) {
synchronized (callLock) {
call = null;
}
rpcTimerContext.close();
Status.Code code = status.getCode();
// OK
if (code == Status.Code.OK) {
if (onOK()) {
opera... | #fixed code
@Override
public void onClose(Status status, Metadata trailers) {
synchronized (callLock) {
call = null;
}
rpcTimerContext.close();
// OK
if (status.isOk()) {
if (onOK(trailers)) {
operationTimerContext.close();
}
} else {
... | Below is the vulnerable code, please generate the patch based on the following information. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.