input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
private PackageDescriptor createPackageDescriptor(File file, BigInteger pDataSize) throws IOException, ParseException {
PackageDescriptor packageDescriptor = new PackageDescriptor(new FileInputStream(file), resolver);
if (packageDescriptor.get("Date") =... | #fixed code
private PackageDescriptor createPackageDescriptor(File file, BigInteger pDataSize) throws IOException, ParseException {
FilteredConfigurationFile controlFile = new FilteredConfigurationFile(file.getName(), new FileInputStream(file), resolver);
PackageDescripto... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void produce( final DataConsumer receiver ) {
TarInputStream archiveInputStream = null;
try {
archiveInputStream = new TarInputStream(new GZIPInputStream(new FileInputStream(archive)));
while(true) {
TarEntry entry = archiveInputStream.getNextEn... | #fixed code
public void produce( final DataConsumer receiver ) {
TarInputStream archiveInputStream = null;
try {
archiveInputStream = new TarInputStream(getCompressedInputStream(new FileInputStream(archive)));
while(true) {
TarEntry entry = archiveInputStream.getNextEnt... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testNoCompression() throws Exception {
project.executeTarget("no-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArInputStream in = new ArInputStream(new File... | #fixed code
public void testNoCompression() throws Exception {
project.executeTarget("no-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArInputStream in = new ArInputStream(new FileInputS... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testBZip2Compression() throws Exception {
project.executeTarget("bzip2-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArInpu... | #fixed code
public void testBZip2Compression() throws Exception {
project.executeTarget("bzip2-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArArchiveInp... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testBZip2Compression() throws Exception {
project.executeTarget("bzip2-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArArch... | #fixed code
public void testBZip2Compression() throws Exception {
project.executeTarget("bzip2-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
final AtomicBoolean found = new AtomicBoolea... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testCreation() throws Exception {
final Processor processor = new Processor(new Console() {
public void println(String s) {
}
}, null);
final File control = new File(getClass().getResource("deb/control/control").toURI());
final File archive1 =... | #fixed code
public void testCreation() throws Exception {
final Processor processor = new Processor(new Console() {
public void println(String s) {
}
}, null);
final File control = new File(getClass().getResource("deb/control/control").toURI());
final File archive1 = new F... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public BinaryPackageControlFile createDeb(Compression compression) throws PackagingException {
File tempData = null;
File tempControl = null;
try {
tempData = File.createTempFile("deb", "data");
tempControl = File.create... | #fixed code
public BinaryPackageControlFile createDeb(Compression compression) throws PackagingException {
File tempData = null;
File tempControl = null;
try {
tempData = File.createTempFile("deb", "data");
tempControl = File.createTempFi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private PackageDescriptor buildControl( final File[] pControlFiles, final BigInteger pDataSize, final StringBuilder pChecksums, final File pOutput ) throws IOException, ParseException {
if (!pOutput.canWrite()) {
throw new IOException("Cannot write ... | #fixed code
private PackageDescriptor buildControl( final File[] pControlFiles, final BigInteger pDataSize, final StringBuilder pChecksums, final File pOutput ) throws IOException, ParseException {
if (!pOutput.canWrite()) {
throw new IOException("Cannot write contro... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void produce( final DataConsumer pReceiver ) throws IOException {
TarInputStream archiveInputStream = null;
try {
archiveInputStream = new TarInputStream(getCompressedInputStream(new FileInputStream(archive)));
while(true... | #fixed code
public void produce( final DataConsumer pReceiver ) throws IOException {
InputStream is = new BufferedInputStream(new FileInputStream(archive));
CompressorInputStream compressorInputStream = null;
try {
// FIXME remove once commons 1.1 is o... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testTarFileSet() throws Exception {
project.executeTarget("tarfileset");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
ArInputStream in = new ArInputStream(new FileInputS... | #fixed code
public void testTarFileSet() throws Exception {
project.executeTarget("tarfileset");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
ArArchiveInputStream in = new ArArchiveInputStream(new Fi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testCreation() throws Exception {
final Processor processor = new Processor(new Console() {
public void println(String s) {
}
}, null);
final File control = new File(getClass().getResource("deb/control/control").toURI());
final File archive1 =... | #fixed code
public void testCreation() throws Exception {
final Processor processor = new Processor(new Console() {
public void println(String s) {
}
}, null);
final File control = new File(getClass().getResource("deb/control/control").toURI());
final File archive1 = new F... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private PackageDescriptor buildControl( final File[] pControlFiles, final BigInteger pDataSize, final StringBuilder pChecksums, final File pOutput ) throws IOException, ParseException {
final File dir = pOutput.getParentFile();
if (dir != null && (!dir.... | #fixed code
private PackageDescriptor buildControl( final File[] pControlFiles, final BigInteger pDataSize, final StringBuilder pChecksums, final File pOutput ) throws IOException, ParseException {
final File dir = pOutput.getParentFile();
if (dir != null && (!dir.exists... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void clearSign(InputStream input, OutputStream output) throws IOException, PGPException, GeneralSecurityException {
int digest = PGPUtil.SHA1;
PGPSignatureGenerator signatureGenerator = new PGPSignatureGenerator(new BcPGPContentSignerBuil... | #fixed code
public void clearSign(InputStream input, OutputStream output) throws IOException, PGPException, GeneralSecurityException {
int digest = PGPUtil.SHA1;
PGPSignatureGenerator signatureGenerator = new PGPSignatureGenerator(new BcPGPContentSignerBuilder(pr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testWrite() throws Exception {
final File out1 = File.createTempFile("jdeb", ".ar");
final ArOutputStream os = new ArOutputStream(new FileOutputStream(out1));
os.putNextEntry(new ArEntry("data", 4));
os.write("data".getBytes(... | #fixed code
public void testWrite() throws Exception {
final File out1 = File.createTempFile("jdeb", ".ar");
final ArArchiveOutputStream os = new ArArchiveOutputStream(new FileOutputStream(out1));
os.putArchiveEntry(new ArArchiveEntry("data", 4));
os.writ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testNoCompression() throws Exception {
project.executeTarget("no-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArInputStream in = new ArInputStream(new File... | #fixed code
public void testNoCompression() throws Exception {
project.executeTarget("no-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArInputStream in = new ArInputStream(new FileInputS... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testControlFilesPermissions() throws Exception {
File deb = new File("target/test-classes/test-control.deb");
if (deb.exists() && !deb.delete()) {
fail("Couldn't delete " + deb);
}
Processor processor = ne... | #fixed code
public void testControlFilesPermissions() throws Exception {
File deb = new File("target/test-classes/test-control.deb");
if (deb.exists() && !deb.delete()) {
fail("Couldn't delete " + deb);
}
Processor processor = new Proc... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testCreateParentDirectories() throws Exception {
File archive = new File("target/data.tar");
if (archive.exists()) {
archive.delete();
}
DataBuilder builder = new DataBuilder(new NullConsole());
... | #fixed code
public void testCreateParentDirectories() throws Exception {
File archive = new File("target/data.tar");
if (archive.exists()) {
archive.delete();
}
DataBuilder builder = new DataBuilder(new NullConsole());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testBZip2Compression() throws Exception {
project.executeTarget("bzip2-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArInpu... | #fixed code
public void testBZip2Compression() throws Exception {
project.executeTarget("bzip2-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArArchiveInp... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testBZip2Compression() throws Exception {
project.executeTarget("bzip2-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArInputStream in = new ArInputStream(ne... | #fixed code
public void testBZip2Compression() throws Exception {
project.executeTarget("bzip2-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArInputStream in = new ArInputStream(new File... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testControlFilesVariables() throws Exception {
File deb = new File("target/test-classes/test-control.deb");
if (deb.exists() && !deb.delete()) {
fail("Couldn't delete " + deb);
}
Map<String, String> variab... | #fixed code
public void testControlFilesVariables() throws Exception {
File deb = new File("target/test-classes/test-control.deb");
if (deb.exists() && !deb.delete()) {
fail("Couldn't delete " + deb);
}
Map<String, String> variables = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static byte[] toUnixLineEndings(InputStream input) throws IOException {
final Charset UTF8 = Charset.forName("UTF-8");
final BufferedReader reader = new BufferedReader(new InputStreamReader(input));
final ByteArrayOutputStream dataStream ... | #fixed code
public static byte[] toUnixLineEndings(InputStream input) throws IOException {
String encoding = "ISO-8859-1";
FixCrLfFilter filter = new FixCrLfFilter(new InputStreamReader(input, encoding));
filter.setEol(FixCrLfFilter.CrLf.newInstance("unix"));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void parse( final InputStream pInput ) throws IOException, ParseException {
final BufferedReader br = new BufferedReader(new InputStreamReader(pInput));
StringBuilder buffer = new StringBuilder();
String key = null;
int linenr =... | #fixed code
protected void parse( final InputStream pInput ) throws IOException, ParseException {
final BufferedReader br = new BufferedReader(new InputStreamReader(pInput, "UTF-8"));
StringBuilder buffer = new StringBuilder();
String key = null;
int linen... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void execute() {
if (control == null || !control.isDirectory()) {
throw new BuildException("You need to point the 'control' attribute to the control directory.");
}
if (changesIn != null) {
if (!changesIn.isFile() || !changesIn.canRead()) {
t... | #fixed code
public void execute() {
if (control == null || !control.isDirectory()) {
throw new BuildException("You need to point the 'control' attribute to the control directory.");
}
if (changesIn != null) {
if (!changesIn.isFile() || !changesIn.canRead()) {
throw n... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testRead() throws Exception {
final File archive = new File(getClass().getResource("data.ar").toURI());
final ArInputStream ar = new ArInputStream(new FileInputStream(archive));
final ArEntry entry1 = ar.getNextEntry();
asse... | #fixed code
public void testRead() throws Exception {
final File archive = new File(getClass().getResource("data.ar").toURI());
final ArArchiveInputStream ar = new ArArchiveInputStream(new FileInputStream(archive));
final ArArchiveEntry entry1 = ar.getNextArEntry... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public PackageDescriptor createDeb( final File[] pControlFiles, final DataProducer[] pData, final File pOutput, String compression ) throws PackagingException, InvalidDescriptorException {
File tempData = null;
File tempControl = null;
try {
... | #fixed code
public PackageDescriptor createDeb( final File[] pControlFiles, final DataProducer[] pData, final File pOutput, String compression ) throws PackagingException, InvalidDescriptorException {
File tempData = null;
File tempControl = null;
try {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testTarFileSet() throws Exception {
project.executeTarget("tarfileset");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
ArInputStream in = new ArInputStream(new FileInputStream(deb));
ArEntry entr... | #fixed code
public void testTarFileSet() throws Exception {
project.executeTarget("tarfileset");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
ArInputStream in = new ArInputStream(new FileInputStream(deb));
ArEntry entry;
w... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testNoCompression() throws Exception {
project.executeTarget("no-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArArchiveInp... | #fixed code
public void testNoCompression() throws Exception {
project.executeTarget("no-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
final AtomicBoolean found = new AtomicBoolean(fals... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void clearSign(InputStream input, OutputStream output) throws IOException, PGPException, GeneralSecurityException {
int digest = PGPUtil.SHA1;
PGPSignatureGenerator signatureGenerator = new PGPSignatureGenerator(new BcPGPContentSignerBuil... | #fixed code
public void clearSign(InputStream input, OutputStream output) throws IOException, PGPException, GeneralSecurityException {
int digest = PGPUtil.SHA1;
PGPSignatureGenerator signatureGenerator = new PGPSignatureGenerator(new BcPGPContentSignerBuilder(pr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testNoCompression() throws Exception {
project.executeTarget("no-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArInputStrea... | #fixed code
public void testNoCompression() throws Exception {
project.executeTarget("no-compression");
File deb = new File("target/test-classes/test.deb");
assertTrue("package not build", deb.exists());
boolean found = false;
ArArchiveInputStre... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void makeDeb() throws PackagingException {
if (control == null || !control.isDirectory()) {
throw new PackagingException(
"\"" + control + "\" is not a valid 'control' directory)");
}
if (changesIn != null) {
... | #fixed code
public void makeDeb() throws PackagingException {
if (control == null || !control.isDirectory()) {
throw new PackagingException(
"\"" + control + "\" is not a valid 'control' directory)");
}
if (changesIn != null) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private PackageDescriptor buildControl( final File[] pControlFiles, final BigInteger pDataSize, final StringBuffer pChecksums, final File pOutput ) throws FileNotFoundException, IOException, ParseException {
PackageDescriptor packageDescriptor = null;
final TarOutput... | #fixed code
private PackageDescriptor buildControl( final File[] pControlFiles, final BigInteger pDataSize, final StringBuffer pChecksums, final File pOutput ) throws FileNotFoundException, IOException, ParseException {
PackageDescriptor packageDescriptor = null;
final TarOutputStream... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testCreation() throws Exception {
final Processor processor = new Processor(new NullConsole(), null);
final File control = new File(getClass().getResource("deb/control/control").toURI());
final File archive1 = new File(getClass().ge... | #fixed code
public void testCreation() throws Exception {
final Processor processor = new Processor(new NullConsole(), null);
final File control = new File(getClass().getResource("deb/control/control").toURI());
final File archive1 = new File(getClass().getResou... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void parse( final InputStream pInput ) throws IOException, ParseException {
final BufferedReader br = new BufferedReader(new InputStreamReader(pInput));
StringBuilder buffer = new StringBuilder();
String key = null;
int linenr =... | #fixed code
protected void parse( final InputStream pInput ) throws IOException, ParseException {
final BufferedReader br = new BufferedReader(new InputStreamReader(pInput, "UTF-8"));
StringBuilder buffer = new StringBuilder();
String key = null;
int linen... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void unpackDependencies() throws MojoExecutionException {
try {
// get plugin JAR
String pluginJarPath = getPluginJarPath();
JarFile pluginJar = new JarFile(new File(pluginJarPath));
// extract loader JAR ... | #fixed code
private void unpackDependencies() throws MojoExecutionException {
ExecutionEnvironment executionEnvironment = executionEnvironment(mavenProject, mavenSession, buildPluginManager);
// try {
executeMojo(
plugin(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void unpackDependencies() throws MojoExecutionException {
getLog().info("Unpacking kumuluzee-loader dependency.");
try {
// get plugin JAR
String pluginJarPath = getPluginJarPath();
JarFile pluginJar = new Jar... | #fixed code
private void unpackDependencies() throws MojoExecutionException {
getLog().info("Unpacking kumuluzee-loader dependency.");
try {
// get plugin JAR
String pluginJarPath = getPluginJarPath();
Path pluginJarFile = Paths.get... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void sendError(final int sc, final String msg) throws IOException {
if (exchange.getExchange().isResponseStarted()) {
throw UndertowServletMessages.MESSAGES.responseAlreadyCommited();
}
if (servletOutputStream != ... | #fixed code
@Override
public void sendError(final int sc, final String msg) throws IOException {
if (exchange.getExchange().isResponseStarted()) {
throw UndertowServletMessages.MESSAGES.responseAlreadyCommited();
}
resetBuffer();
writer = n... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected StreamSinkFrameChannel create(StreamSinkChannel channel, WebSocketFrameType type, long payloadSize) {
return new WebSocket08FrameSinkChannel(channel, this, type, payloadSize);
}
#location 3
... | #fixed code
@Override
protected StreamSinkFrameChannel create(StreamSinkChannel channel, WebSocketFrameType type, long payloadSize) {
switch (type) {
case TEXT:
return new WebSocket08TextFrameSinkChannel(channel, this, payloadSize);
cas... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public HttpSession getSession(final boolean create) {
if (httpSession == null) {
Session session = exchange.getExchange().getAttachment(Session.ATTACHMENT_KEY);
if (session != null) {
httpSession = new HttpSe... | #fixed code
@Override
public HttpSession getSession(final boolean create) {
return servletContext.getSession(exchange.getExchange(), create);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@GET
@Path("/start")
@Metric(HTTP_STOP_OTA)
public Response startOTA(@QueryParam("fileName") String filename,
@QueryParam("token") String token) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
... | #fixed code
@GET
@Path("/start")
@Metric(HTTP_STOP_OTA)
public Response startOTA(@QueryParam("fileName") String filename,
@QueryParam("token") String token) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (t... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testGetWithFakeToken() throws Exception {
String token = "4ae3851817194e2596cf1b7103603ef8";
HttpGet request = new HttpGet(httpsServerUrl + token + "/project");
InputStream is = getClass().getResourceAsStream("/profiles/u_d... | #fixed code
@Test
public void testGetWithFakeToken() throws Exception {
String token = "4ae3851817194e2596cf1b7103603ef8";
HttpGet request = new HttpGet(httpsServerUrl + token + "/project");
InputStream is = getClass().getResourceAsStream("/profiles/u_dmitriy... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void channelRead0(ChannelHandlerContext ctx, SaveProfileMessage message) throws Exception {
String userProfileString = message.body;
//expecting message with 2 parts
if (userProfileString == null || userProfileString.equa... | #fixed code
@Override
protected void channelRead0(ChannelHandlerContext ctx, SaveProfileMessage message) throws Exception {
String userProfileString = message.body;
//expecting message with 2 parts
if (userProfileString == null || userProfileString.equals("")... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void messageReceived(ChannelHandlerContext ctx, Message message) {
String token = message.body;
User userThatShared = userDao.sharedTokenManager.getUserByToken(token);
if (userThatShared == null) {
throw new InvalidTokenExcep... | #fixed code
public void messageReceived(ChannelHandlerContext ctx, Message message) {
String token = message.body;
User userThatShared = userDao.sharedTokenManager.getUserByToken(token);
if (userThatShared == null) {
throw new InvalidTokenException("... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void channelRead0(ChannelHandlerContext ctx, GetTokenMessage message) throws Exception {
String dashBoardIdString = message.body;
Long dashBoardId;
try {
dashBoardId = Long.parseLong(dashBoardIdString);
... | #fixed code
@Override
protected void channelRead0(ChannelHandlerContext ctx, GetTokenMessage message) throws Exception {
String dashBoardIdString = message.body;
Long dashBoardId;
try {
dashBoardId = Long.parseLong(dashBoardIdString);
} ca... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void messageReceived(ChannelHandlerContext ctx, HardwareStateHolder state, StringMessage message) {
Session session = sessionDao.userSession.get(state.user);
String[] bodyParts = message.body.split(StringUtils.BODY_SEPARATOR_STRING);
if ... | #fixed code
public void messageReceived(ChannelHandlerContext ctx, HardwareStateHolder state, StringMessage message) {
Session session = sessionDao.userSession.get(state.user);
String[] bodyParts = message.body.split(StringUtils.BODY_SEPARATOR_STRING);
if (bodyP... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws Exception {
TokenManager tokenManager = new TokenManager(new ConcurrentHashMap<>(), null, null, "");
String email = "dmitriy@blynk.cc";
String pass = "b";
String appName = AppName.BLYNK;
... | #fixed code
public static void main(String[] args) throws Exception {
TokenManager tokenManager = new TokenManager(new ConcurrentHashMap<>(), null, null, "");
String email = "dmitriy@blynk.cc";
String pass = "b";
String appName = AppName.BLYNK;
Use... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Response singleDeviceOTA(ChannelHandlerContext ctx, String token, String path) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (tokenValue == null) {
log.debug("Requested token {} not found.", token);
... | #fixed code
private Response singleDeviceOTA(ChannelHandlerContext ctx, String token, String path) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (tokenValue == null) {
log.debug("Requested token {} not found.", token);
ret... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void messageReceived(ChannelHandlerContext ctx, Message message) {
String token = message.body;
User userThatShared = userRegistry.sharedTokenManager.getUserByToken(token);
if (userThatShared == null) {
throw new InvalidToken... | #fixed code
public void messageReceived(ChannelHandlerContext ctx, Message message) {
String token = message.body;
User userThatShared = userRegistry.sharedTokenManager.getUserByToken(token);
if (userThatShared == null) {
throw new InvalidTokenExcept... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDeleteCommand() throws IOException {
StorageWorker storageWorker = new StorageWorker(averageAggregator, reportingFolder, new DBManager(null));
ConcurrentHashMap<AggregationKey, AggregationValue> map = new ConcurrentHashMap<>();... | #fixed code
@Test
public void testDeleteCommand() throws IOException {
StorageWorker storageWorker = new StorageWorker(averageAggregator, reportingFolder, new DBManager());
ConcurrentHashMap<AggregationKey, AggregationValue> map = new ConcurrentHashMap<>();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void sendPushNotification(DashBoard dashBoard, Notification notification, int dashId, int deviceId) {
Device device = dashBoard.getDeviceById(deviceId);
final String dashName = dashBoard.name == null ? "" : dashBoard.name;
final String de... | #fixed code
private void sendPushNotification(DashBoard dashBoard, Notification notification, int dashId, int deviceId) {
Device device = dashBoard.getDeviceById(deviceId);
final String dashName = dashBoard.name == null ? "" : dashBoard.name;
final String deviceNa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
String assignToken(User user, int dashId, int deviceId, String newToken) {
// Clean old token from cache if exists.
DashBoard dash = user.profile.getDashByIdOrThrow(dashId);
Device device = dash.getDeviceById(deviceId);
String oldToken =... | #fixed code
RegularTokenManager(Iterable<User> users) {
this.cache = new ConcurrentHashMap<String, TokenValue>() {{
for (User user : users) {
if (user.profile != null) {
for (DashBoard dashBoard : user.profile.dashBoards) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@POST
@Path("{token}/email")
@Consumes(value = MediaType.APPLICATION_JSON)
public Response email(@PathParam("token") String token,
EmailPojo message) {
globalStats.mark(HTTP_EMAIL);
User user = tokenM... | #fixed code
@POST
@Path("{token}/email")
@Consumes(value = MediaType.APPLICATION_JSON)
public Response email(@PathParam("token") String token,
EmailPojo message) {
globalStats.mark(HTTP_EMAIL);
TokenValue tokenValue = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@GET
@Path("{token}/pin/{pin}")
@Metric(HTTP_GET_PIN_DATA)
public Response getWidgetPinData(@PathParam("token") String token,
@PathParam("pin") String pinString) {
TokenValue tokenValue = tokenManager.getTokenVal... | #fixed code
@GET
@Path("{token}/pin/{pin}")
@Metric(HTTP_GET_PIN_DATA)
public Response getWidgetPinData(@PathParam("token") String token,
@PathParam("pin") String pinString) {
TokenValue tokenValue = tokenManager.getTokenValueByTo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@GET
@Path("{token}/project")
@Metric(HTTP_GET_PROJECT)
public Response getDashboard(@PathParam("token") String token) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (tokenValue == null) {
log.debug("Reque... | #fixed code
@GET
@Path("{token}/project")
@Metric(HTTP_GET_PROJECT)
public Response getDashboard(@PathParam("token") String token) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (tokenValue == null) {
log.debug("Requested t... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void messageReceived(ChannelHandlerContext ctx, User user, StringMessage message) {
String[] split = StringUtils.split2(message.body);
int dashId = ParseUtil.parseInt(split[0]);
int deviceId = 0;
//new value for multi devices
... | #fixed code
public void messageReceived(ChannelHandlerContext ctx, User user, StringMessage message) {
String[] split = StringUtils.split2(message.body);
int dashId = ParseUtil.parseInt(split[0]);
DashBoard dash = user.profile.getDashByIdOrThrow(dashId);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@PUT
@Path("/{token}/widget/{pin}")
@Consumes(value = MediaType.APPLICATION_JSON)
public Response updateWidgetPinData(@PathParam("token") String token,
@PathParam("pin") String pinString,
... | #fixed code
@PUT
@Path("/{token}/widget/{pin}")
@Consumes(value = MediaType.APPLICATION_JSON)
public Response updateWidgetPinData(@PathParam("token") String token,
@PathParam("pin") String pinString,
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Response updateWidgetProperty(String token,
String pinString,
String property,
String... values) {
if (values.length == 0) {
... | #fixed code
public Response updateWidgetProperty(String token,
String pinString,
String property,
String... values) {
if (values.length == 0) {
l... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void parseHardwareInfo(ChannelHandlerContext ctx, String[] messageParts, HardwareStateHolder state, int msgId) {
HardwareInfo hardwareInfo = new HardwareInfo(messageParts);
int newHardwareInterval = hardwareInfo.heartbeatInterval;
log.tr... | #fixed code
private void parseHardwareInfo(ChannelHandlerContext ctx, String[] messageParts, HardwareStateHolder state, int msgId) {
HardwareInfo hardwareInfo = new HardwareInfo(messageParts);
int newHardwareInterval = hardwareInfo.heartbeatInterval;
log.trace("I... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
@Ignore
public void testGetTestString() {
RealRedisClient redisClient = new RealRedisClient("localhost", "123", 6378);
String result = redisClient.getServerByToken("test");
assertEquals("It's working!", result);
}
... | #fixed code
@Test
@Ignore
public void testGetTestString() {
RedisClient redisClient = new RedisClient("localhost", "123", 6378, false);
String result = redisClient.getServerByToken("test");
assertEquals("It's working!", result);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Response singleDeviceOTA(ChannelHandlerContext ctx, String token, String path) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (tokenValue == null) {
log.debug("Requested token {} not found.", token);
... | #fixed code
private Response singleDeviceOTA(ChannelHandlerContext ctx, String token, String path) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (tokenValue == null) {
log.debug("Requested token {} not found.", token);
ret... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
String assignToken(User user, int dashId, int deviceId, String newToken) {
// Clean old token from cache if exists.
DashBoard dash = user.profile.getDashByIdOrThrow(dashId);
Device device = dash.getDeviceById(deviceId);
String oldToken =... | #fixed code
String assignToken(User user, int dashId, int deviceId, String newToken) {
// Clean old token from cache if exists.
DashBoard dash = user.profile.getDashByIdOrThrow(dashId);
Device device = dash.getDeviceById(deviceId);
String oldToken = remov... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testStore2() throws IOException {
StorageWorker storageWorker = new StorageWorker(averageAggregator, reportingFolder, new DBManager(null));
ConcurrentHashMap<AggregationKey, AggregationValue> map = new ConcurrentHashMap<>();
... | #fixed code
@Test
public void testStore2() throws IOException {
StorageWorker storageWorker = new StorageWorker(averageAggregator, reportingFolder, new DBManager());
ConcurrentHashMap<AggregationKey, AggregationValue> map = new ConcurrentHashMap<>();
long ts... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@GET
@Path("/start")
@Metric(HTTP_STOP_OTA)
public Response startOTA(@QueryParam("fileName") String filename,
@QueryParam("token") String token) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
... | #fixed code
@GET
@Path("/start")
@Metric(HTTP_STOP_OTA)
public Response startOTA(@QueryParam("fileName") String filename,
@QueryParam("token") String token) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (t... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@GET
@Path("{token}/rtc")
@Metric(HTTP_GET_PIN_DATA)
public Response getWidgetPinData(@PathParam("token") String token) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (tokenValue == null) {
log.debug("Requ... | #fixed code
@GET
@Path("{token}/rtc")
@Metric(HTTP_GET_PIN_DATA)
public Response getWidgetPinData(@PathParam("token") String token) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (tokenValue == null) {
log.debug("Requested ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static void add(Set<String> doNotRemovePaths, DashBoard dash, EnhancedHistoryGraph graph) {
for (GraphDataStream graphDataStream : graph.dataStreams) {
if (graphDataStream != null && graphDataStream.dataStream != null && graphDataStream.dataS... | #fixed code
private static void add(Set<String> doNotRemovePaths, DashBoard dash, EnhancedHistoryGraph graph) {
for (GraphDataStream graphDataStream : graph.dataStreams) {
if (graphDataStream != null && graphDataStream.dataStream != null && graphDataStream.dataStream.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static List<String> find(String staticResourcesFolder) throws Exception {
CodeSource src = ServerLauncher.class.getProtectionDomain().getCodeSource();
List<String> staticResources = new ArrayList<>();
if (src != null) {
URL ja... | #fixed code
public static List<String> find(String staticResourcesFolder) throws Exception {
CodeSource src = ServerLauncher.class.getProtectionDomain().getCodeSource();
List<String> staticResources = new ArrayList<>();
if (src != null) {
URL jar = sr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) {
List<FlashedToken> flashedTokens = generateTokens(10, AppName.BLYNK, 1);
DBManager dbManager = new DBManager("db-test.properties", new BlockingIOProcessor(1, 100, null));
dbManager.insertFlashedTokens(flas... | #fixed code
public static void main(String[] args) throws Exception{
List<FlashedToken> flashedTokens = generateTokens(100, "Grow", 2);
DBManager dbManager = new DBManager("db-test.properties", new BlockingIOProcessor(1, 100, null));
dbManager.insertFlashedTokens... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void messageReceived(ChannelHandlerContext ctx, User user, StringMessage message) {
String[] split = split2(message.body);
if (split.length < 2) {
throw new IllegalCommandException("Wrong income message format.");
}
i... | #fixed code
public void messageReceived(ChannelHandlerContext ctx, User user, StringMessage message) {
String[] split = split2(message.body);
if (split.length < 2) {
throw new IllegalCommandException("Wrong income message format.");
}
int das... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testStore() throws IOException {
StorageWorker storageWorker = new StorageWorker(averageAggregator, reportingFolder, new DBManager(null));
ConcurrentHashMap<AggregationKey, AggregationValue> map = new ConcurrentHashMap<>();
... | #fixed code
@Test
public void testStore() throws IOException {
StorageWorker storageWorker = new StorageWorker(averageAggregator, reportingFolder, new DBManager());
ConcurrentHashMap<AggregationKey, AggregationValue> map = new ConcurrentHashMap<>();
long ts ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
@Ignore
public void testIOS() throws Exception {
GCMWrapper gcmWrapper = new GCMWrapper(null, null);
gcmWrapper.send(new IOSGCMMessage("to", Priority.normal, "yo!!!", 1), null, null);
}
#location 4
... | #fixed code
@Test
@Ignore
public void testIOS() throws Exception {
GCMWrapper gcmWrapper = new GCMWrapper(props, client);
gcmWrapper.send(new IOSGCMMessage("to", Priority.normal, "yo!!!", 1), null, null);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@GET
@Path("/{projectId}")
public Response getProject(@Context User user,
@PathParam("projectId") int projectId) {
DashBoard project = user.profile.getDashById(projectId);
project.token = user.dashTokens.get(projectI... | #fixed code
@GET
@Path("/{projectId}")
public Response getProject(@Context User user,
@PathParam("projectId") int projectId) {
DashBoard project = user.profile.getDashById(projectId);
//project.token = user.dashTokens.get(projectId);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@GET
@Path("{token}/isAppConnected")
@Metric(HTTP_IS_APP_CONNECTED)
public Response isAppConnected(@PathParam("token") String token) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (tokenValue == null) {
lo... | #fixed code
@GET
@Path("{token}/isAppConnected")
@Metric(HTTP_IS_APP_CONNECTED)
public Response isAppConnected(@PathParam("token") String token) {
TokenValue tokenValue = tokenManager.getTokenValueByToken(token);
if (tokenValue == null) {
log.debu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void channelRead0(ChannelHandlerContext ctx, LoadProfileMessage message) throws Exception {
User authUser = Session.findUserByChannel(ctx.channel());
String body = authUser.getUserProfile() == null ? "{}" : authUser.getUserProfil... | #fixed code
@Override
protected void channelRead0(ChannelHandlerContext ctx, LoadProfileMessage message) throws Exception {
User authUser = Session.findUserByChannel(ctx.channel(), message.id);
String body = authUser.getUserProfile() == null ? "{}" : authUser.getUser... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@POST
@Path("{token}/notify")
@Consumes(value = MediaType.APPLICATION_JSON)
@Metric(HTTP_NOTIFY)
public Response notify(@PathParam("token") String token,
PushMessagePojo message) {
TokenValue tokenValue = tokenManager.... | #fixed code
@POST
@Path("{token}/notify")
@Consumes(value = MediaType.APPLICATION_JSON)
@Metric(HTTP_NOTIFY)
public Response notify(@PathParam("token") String token,
PushMessagePojo message) {
TokenValue tokenValue = tokenManager.getTok... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
@Ignore
public void testAndroid() throws Exception {
GCMWrapper gcmWrapper = new GCMWrapper(null, null);
gcmWrapper.send(new AndroidGCMMessage("", Priority.normal, "yo!!!", 1), null, null);
}
#location 4
... | #fixed code
@Test
@Ignore
public void testAndroid() throws Exception {
when(props.getProperty("gcm.api.key")).thenReturn("");
when(props.getProperty("gcm.server")).thenReturn("");
GCMWrapper gcmWrapper = new GCMWrapper(props, client);
gcmWrapper.se... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static String unCompress(String str) throws IOException {
if (null == str || str.length() <= 0) {
return str;
}
// 创建一个新的 byte 数组输出流
ByteArrayOutputStream out = new ByteArrayOutputStream();
// 创建一个 ByteArrayInpu... | #fixed code
public static String unCompress(String str) throws IOException {
if (null == str || str.length() <= 0) {
return str;
}
try (
// 创建一个新的 byte 数组输出流
ByteArrayOutputStream out = new ByteArrayOutputStream();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static String unCompress(String str) throws IOException {
if (null == str || str.length() <= 0) {
return str;
}
// 创建一个新的 byte 数组输出流
ByteArrayOutputStream out = new ByteArrayOutputStream();
// 创建一个 ByteArrayInpu... | #fixed code
public static String unCompress(String str) throws IOException {
if (null == str || str.length() <= 0) {
return str;
}
try (
// 创建一个新的 byte 数组输出流
ByteArrayOutputStream out = new ByteArrayOutputStream();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
void testThrowsExceptionWithNullTestInstance() throws Exception {
Object optionsFromAnnotatedField = annotationsReader
.getOptionsFromAnnotatedField(null, Options.class);
assertThat(optionsFromAnnotatedField, nullValue());
}... | #fixed code
@Test
void testThrowsExceptionWithNullTestInstance() throws Exception {
assertThrows(NullPointerException.class, () -> {
annotationsReader.getOptionsFromAnnotatedField(null, Options.class);
});
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String startContainer(DockerContainer dockerContainer)
throws DockerException, InterruptedException {
String imageId = dockerContainer.getImageId();
log.info("Starting Docker container {}", imageId);
com.spotify.docker.client.m... | #fixed code
public String startContainer(DockerContainer dockerContainer)
throws DockerException, InterruptedException {
String imageId = dockerContainer.getImageId();
log.info("Starting Docker container {}", imageId);
com.spotify.docker.client.message... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
private DriverHandler getDriverHandler(ExtensionContext extensionContext,
Parameter parameter, Class<?> type, Integer index,
Class<?> constructorClass, boolean isRemote)
throws InstantiationException... | #fixed code
@SuppressWarnings("unchecked")
private DriverHandler getDriverHandler(ExtensionContext extensionContext,
Parameter parameter, Class<?> type, Integer index,
Class<?> constructorClass, boolean isRemote)
throws InstantiationException, Ille... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void stopService() {
this.stop = true;
writer.stopService();
}
#location 4
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
public void stopService() {
this.stop = true;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() throws Exception {
TChannel tchannel = new TChannel.Builder("ping-client").build();
Req<Ping> req = new Req<Ping>(
"ping",
new HashMap<String, String>() {
{
pu... | #fixed code
public void run() throws Exception {
TChannel tchannel = new TChannel.Builder("ping-client").build();
Map<String, String> headers = new HashMap<String, String>() {
{
put("some", "header");
}
};
Request<... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() throws Exception {
TChannel tchannel = new TChannel.Builder("ping-server")
.register("ping", new PingRequestHandler())
.setPort(this.port)
.build();
tchannel.listen().channel().closeFutur... | #fixed code
public void run() throws Exception {
TChannel tchannel = new TChannel.Builder("ping-server")
.register("ping", new PingRequestHandler())
.setServerPort(this.port)
.build();
tchannel.listen().channel().closeFutur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
long missCount()
{
return missCount;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
OffHeapMap(OHCacheBuilder builder, AtomicLong freeCapacity)
{
this.freeCapacity = freeCapacity;
int hts = builder.getHashTableSize();
if (hts <= 0)
hts = 8192;
if (hts < 256)
hts = 256;
int bl = builder.getB... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
long removeCount()
{
return removeCount;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
OffHeapMap(OHCacheBuilder builder, AtomicLong freeCapacity)
{
this.freeCapacity = freeCapacity;
int hts = builder.getHashTableSize();
if (hts <= 0)
hts = 8192;
if (hts < 256)
hts = 256;
table = Table.create(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void resetStatistics()
{
rehashes = 0L;
evictedEntries = 0L;
hitCount = 0L;
missCount = 0L;
putAddCount = 0L;
putReplaceCount = 0L;
removeCount = 0L;
lruCompactions = 0L;
}
... | #fixed code
OffHeapMap(OHCacheBuilder builder, long freeCapacity)
{
this.freeCapacity = freeCapacity;
this.throwOOME = builder.isThrowOOME();
this.lock = builder.isUnlocked() ? null : new ReentrantLock();
int hts = builder.getHashTableSize();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void resetStatistics()
{
rehashes = 0L;
evictedEntries = 0L;
hitCount = 0L;
missCount = 0L;
putAddCount = 0L;
putReplaceCount = 0L;
removeCount = 0L;
}
#location 5
... | #fixed code
OffHeapMap(OHCacheBuilder builder, long freeCapacity)
{
this.freeCapacity = freeCapacity;
this.throwOOME = builder.isThrowOOME();
this.lock = builder.isUnlocked() ? null : new ReentrantLock();
int hts = builder.getHashTableSize();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
long size()
{
return size;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
OffHeapMap(OHCacheBuilder builder, long capacity, long cleanUpTriggerFree)
{
this.capacity = capacity;
this.freeCapacity = capacity;
this.cleanUpTriggerFree = cleanUpTriggerFree;
int hts = builder.getHashTableSize();
if (hts <= 0)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
long rehashes()
{
return rehashes;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
OffHeapMap(OHCacheBuilder builder, long capacity, long cleanUpTriggerFree)
{
this.capacity = capacity;
this.freeCapacity = capacity;
this.cleanUpTriggerFree = cleanUpTriggerFree;
int hts = builder.getHashTableSize();
if (hts <= 0)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
long missCount()
{
return missCount;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
OffHeapMap(OHCacheBuilder builder, long freeCapacity)
{
this.freeCapacity = freeCapacity;
this.throwOOME = builder.isThrowOOME();
this.lock = builder.isUnlocked() ? null : new ReentrantLock();
int hts = builder.getHashTableSize();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
long cleanUpCount()
{
return cleanUpCount;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
OffHeapMap(OHCacheBuilder builder, long capacity, long cleanUpTriggerFree, long cleanUpTargetFree)
{
this.capacity = capacity;
this.freeCapacity = capacity;
this.cleanUpTriggerFree = cleanUpTriggerFree;
this.cleanUpTargetFree = cleanUpTarge... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
long putReplaceCount()
{
return putReplaceCount;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
OffHeapMap(OHCacheBuilder builder, AtomicLong freeCapacity)
{
this.freeCapacity = freeCapacity;
int hts = builder.getHashTableSize();
if (hts <= 0)
hts = 8192;
if (hts < 256)
hts = 256;
table = Table.create(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void resetStatistics()
{
rehashes = 0L;
evictedEntries = 0L;
hitCount = 0L;
missCount = 0L;
putAddCount = 0L;
putReplaceCount = 0L;
removeCount = 0L;
lruCompactions = 0L;
}
... | #fixed code
OffHeapMap(OHCacheBuilder builder, AtomicLong freeCapacity)
{
this.freeCapacity = freeCapacity;
int hts = builder.getHashTableSize();
if (hts <= 0)
hts = 8192;
if (hts < 256)
hts = 256;
int bl = builder.getB... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
long evictedEntries()
{
return evictedEntries;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
OffHeapMap(OHCacheBuilder builder, long freeCapacity)
{
this.freeCapacity = freeCapacity;
this.throwOOME = builder.isThrowOOME();
this.lock = builder.isUnlocked() ? null : new ReentrantLock();
int hts = builder.getHashTableSize();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void resetStatistics()
{
rehashes = 0L;
evictedEntries = 0L;
hitCount = 0L;
missCount = 0L;
putAddCount = 0L;
putReplaceCount = 0L;
removeCount = 0L;
lruCompactions = 0L;
}
... | #fixed code
OffHeapMap(OHCacheBuilder builder, AtomicLong freeCapacity)
{
this.freeCapacity = freeCapacity;
int hts = builder.getHashTableSize();
if (hts <= 0)
hts = 8192;
if (hts < 256)
hts = 256;
int bl = builder.getB... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void resetStatistics()
{
rehashes = 0L;
evictedEntries = 0L;
hitCount = 0L;
missCount = 0L;
putAddCount = 0L;
putReplaceCount = 0L;
removeCount = 0L;
lruCompactions = 0L;
}
... | #fixed code
OffHeapMap(OHCacheBuilder builder, long freeCapacity)
{
this.freeCapacity = freeCapacity;
this.throwOOME = builder.isThrowOOME();
this.lock = builder.isUnlocked() ? null : new ReentrantLock();
int hts = builder.getHashTableSize();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void resetStatistics()
{
rehashes = 0L;
evictedEntries = 0L;
hitCount = 0L;
missCount = 0L;
putAddCount = 0L;
putReplaceCount = 0L;
removeCount = 0L;
}
#location 4
... | #fixed code
OffHeapMap(OHCacheBuilder builder, long freeCapacity)
{
this.freeCapacity = freeCapacity;
this.throwOOME = builder.isThrowOOME();
this.lock = builder.isUnlocked() ? null : new ReentrantLock();
int hts = builder.getHashTableSize();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
int hashTableSize()
{
return table.size();
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
OffHeapMap(OHCacheBuilder builder, AtomicLong freeCapacity)
{
this.freeCapacity = freeCapacity;
int hts = builder.getHashTableSize();
if (hts <= 0)
hts = 8192;
if (hts < 256)
hts = 256;
int bl = builder.getB... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
boolean replaceEntry(long hash, long oldHashEntryAdr, long newHashEntryAdr, long bytes)
{
LongArrayList derefList = null;
lock.lock();
try
{
long prevEntryAdr = 0L;
for (long hashEntryAdr = table.getFirst(hash... | #fixed code
OffHeapMap(OHCacheBuilder builder, long freeCapacity)
{
this.freeCapacity = freeCapacity;
this.throwOOME = builder.isThrowOOME();
this.lock = builder.isUnlocked() ? null : new ReentrantLock();
int hts = builder.getHashTableSize();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
long freeCapacity()
{
return freeCapacity;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
OffHeapMap(OHCacheBuilder builder, long capacity, long cleanUpTriggerFree)
{
this.capacity = capacity;
this.freeCapacity = capacity;
this.cleanUpTriggerFree = cleanUpTriggerFree;
int hts = builder.getHashTableSize();
if (hts <= 0)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void resetStatistics()
{
rehashes = 0L;
evictedEntries = 0L;
hitCount = 0L;
missCount = 0L;
putAddCount = 0L;
putReplaceCount = 0L;
removeCount = 0L;
}
#location 6
... | #fixed code
OffHeapMap(OHCacheBuilder builder, long freeCapacity)
{
this.freeCapacity = freeCapacity;
this.throwOOME = builder.isThrowOOME();
this.lock = builder.isUnlocked() ? null : new ReentrantLock();
int hts = builder.getHashTableSize();
... | 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.