input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code @Override public void put(String cacheName, Object key, Object value, int liveSeconds) { try { ehcache.put(cacheName, key, value, liveSeconds); redisCache.put(cacheName, key, value, liveSeconds); } finally { Jboot....
#fixed code @Override public void put(String cacheName, Object key, Object value, int liveSeconds) { try { ehcache.put(cacheName, key, value, liveSeconds); redisCache.put(cacheName, key, value, liveSeconds); } finally { publishMessa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean save() { if (hasColumn(COLUMN_CREATED) && get(COLUMN_CREATED) == null) { set(COLUMN_CREATED, new Date()); } if (null == get(getPrimaryKey()) && String.class == getPrimaryType()) { set(getPrimar...
#fixed code @Override public boolean save() { if (hasColumn(COLUMN_CREATED) && get(COLUMN_CREATED) == null) { set(COLUMN_CREATED, new Date()); } if (null == get(getPrimaryKey()) && String.class == getPrimaryType()) { set(getPrimaryKey()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @RequiresPermissions("adminSystemVariable") @RequestMapping(value="variableSave${url.suffix}", method = RequestMethod.POST) @ResponseBody public BaseVO variableSave(System sys, Model model, HttpServletRequest request){ System system; if(Global.system.get(sys.getN...
#fixed code @RequiresPermissions("adminSystemVariable") @RequestMapping(value="variableSave${url.suffix}", method = RequestMethod.POST) @ResponseBody public BaseVO variableSave(System sys, Model model, HttpServletRequest request){ System system = sqlService.findAloneByProperty(System.c...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @RequestMapping(value="saveTemplateName${url.suffix}", method = RequestMethod.POST) @ResponseBody public BaseVO saveTemplateName(HttpServletRequest request, @RequestParam(value = "templateName", required = false, defaultValue="") String templateName){ if(!haveSiteA...
#fixed code @RequestMapping(value="saveTemplateName${url.suffix}", method = RequestMethod.POST) @ResponseBody public BaseVO saveTemplateName(HttpServletRequest request, @RequestParam(value = "templateName", required = false, defaultValue="") String templateName){ if(!haveSiteAuth())...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public TemplatePageVO saveTemplatePageText(String fileName, String html, HttpServletRequest request) { TemplatePageVO vo = new TemplatePageVO(); fileName = Safety.filter(fileName); if(fileName == null || fileName.length() == 0){ vo.setBaseVO(BaseVO.FAILURE, "出错...
#fixed code public TemplatePageVO saveTemplatePageText(String fileName, String html, HttpServletRequest request) { TemplatePageVO vo = new TemplatePageVO(); fileName = Safety.filter(fileName); if(fileName == null || fileName.length() == 0){ vo.setBaseVO(BaseVO.FAILURE, "出错,你要修改的...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public BaseVO refreshForTemplate(HttpServletRequest request){ BaseVO vo = new BaseVO(); Site site = Func.getCurrentSite(); TemplateCMS template = new TemplateCMS(site); //取得当前网站所有模版页面 // TemplatePageListVO templatePageListVO = templateService.getTemplatePageLis...
#fixed code public BaseVO refreshForTemplate(HttpServletRequest request){ BaseVO vo = new BaseVO(); Site site = Func.getCurrentSite(); if(site == null){ vo.setBaseVO(BaseVO.FAILURE, "尚未登陆"); return vo; } TemplateCMS template = new TemplateCMS(site); //取得当前网站所有模版页面 // T...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @RequestMapping(value="uploadImportTemplate${url.suffix}", method = RequestMethod.POST) @ResponseBody public void uploadImportTemplate(HttpServletResponse response, HttpServletRequest request, @RequestParam("templateFile") MultipartFile multipartFile){ if(multipart...
#fixed code @RequestMapping(value="uploadImportTemplate${url.suffix}", method = RequestMethod.POST) @ResponseBody public void uploadImportTemplate(HttpServletResponse response, HttpServletRequest request, @RequestParam("templateFile") MultipartFile multipartFile){ if(multipartFile =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static UploadFileVO put(String path,InputStream inputStream){ UploadFileVO vo = new UploadFileVO(); if(isMode(MODE_ALIYUN_OSS)){ PutResult pr = OSSUtil.put(path, inputStream); vo = PutResultToUploadFileVO(pr); }else if(isMode(MODE_LOCAL_FILE)){ dir...
#fixed code public static UploadFileVO put(String path,InputStream inputStream){ UploadFileVO vo = new UploadFileVO(); //判断文件大小是否超出最大限制的大小 int lengthKB = 0; try { lengthKB = (int) Math.ceil(inputStream.available()/1024); } catch (IOException e) { e.printStackTrace(); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void connect() throws IOException, InterruptedException, ServiceLocatorException { connect(false); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public void connect() throws IOException, InterruptedException, ServiceLocatorException { try { synchronized (this) { if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "Start connect session"); } blockedByRunUpOperation = true; connect(false); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void disconnect() throws InterruptedException, ServiceLocatorException { disconnect(true, false); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public void disconnect() throws InterruptedException, ServiceLocatorException { try { synchronized (this) { if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "Start disconnect session"); } blockedByRunUpOperation = true; disconnect(false); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Keyspace keyspace() { if (keyspace != null) return keyspace; synchronized (AstyanaxConnection.class) { // double check... if (keyspace != null) return keyspace; try ...
#fixed code public Keyspace keyspace() { if (keyspace != null) return keyspace; synchronized (AstyanaxConnection.class) { // double check... if (keyspace != null) return keyspace; try ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReframe() throws Exception { final ZMTPParser parser = ZMTPParser.create(ZMTP10, new RawDecoder()); final ZMTPWriter writer = ZMTPWriter.create(ZMTP10); final ByteBuf buf = Unpooled.buffer(); writer.reset(buf); // Request a fr...
#fixed code @Test public void testReframe() throws Exception { final ZMTPFramingDecoder decoder = new ZMTPFramingDecoder(wireFormat(ZMTP10), new RawDecoder()); final ZMTPWriter writer = ZMTPWriter.create(ZMTP10); final ByteBuf buf = Unpooled.buffer(); writer.reset(buf); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSingleFrame() throws Exception { final ZMTPMessageDecoder decoder = new ZMTPMessageDecoder(); final ByteBuf content = Unpooled.copiedBuffer("hello", UTF_8); final List<Object> out = Lists.newArrayList(); decoder.header(content.rea...
#fixed code @Test public void testSingleFrame() throws Exception { final ZMTPMessageDecoder decoder = new ZMTPMessageDecoder(); final ByteBuf content = Unpooled.copiedBuffer("hello", UTF_8); final List<Object> out = Lists.newArrayList(); decoder.header(content.readableB...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testOneFrame() throws Exception { final ZMTPWriter writer = ZMTPWriter.create(ZMTP10); final ByteBuf buf = Unpooled.buffer(); writer.reset(buf); ByteBuf frame = writer.frame(11, false); assertThat(frame, is(sameInstance(buf))); ...
#fixed code @Test public void testOneFrame() throws Exception { final ZMTPWriter writer = ZMTPWriter.create(ZMTP10); final ByteBuf buf = Unpooled.buffer(); writer.reset(buf); ByteBuf frame = writer.frame(11, false); assertThat(frame, is(sameInstance(buf))); fina...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReframe() throws Exception { final ZMTPParser parser = ZMTPParser.create(ZMTP10, new RawDecoder()); final ZMTPWriter writer = ZMTPWriter.create(ZMTP10); final ByteBuf buf = Unpooled.buffer(); writer.reset(buf); // Request a fr...
#fixed code @Test public void testReframe() throws Exception { final ZMTPFramingDecoder decoder = new ZMTPFramingDecoder(wireFormat(ZMTP10), new RawDecoder()); final ZMTPWriter writer = ZMTPWriter.create(ZMTP10); final ByteBuf buf = Unpooled.buffer(); writer.reset(buf); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testTwoFrames() throws Exception { final ZMTPMessageDecoder decoder = new ZMTPMessageDecoder(); final ByteBuf f0 = Unpooled.copiedBuffer("hello", UTF_8); final ByteBuf f1 = Unpooled.copiedBuffer("world", UTF_8); final List<Object> out...
#fixed code @Test public void testTwoFrames() throws Exception { final ZMTPMessageDecoder decoder = new ZMTPMessageDecoder(); final ByteBuf f0 = Unpooled.copiedBuffer("hello", UTF_8); final ByteBuf f1 = Unpooled.copiedBuffer("world", UTF_8); final List<Object> out = Lis...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testTwoFrames() throws Exception { final ZMTPWriter writer = ZMTPWriter.create(ZMTP10); final ByteBuf buf = Unpooled.buffer(); writer.reset(buf); final ByteBuf f0 = copiedBuffer("hello ", UTF_8); final ByteBuf f1 = copiedBuffer("he...
#fixed code @Test public void testTwoFrames() throws Exception { final ZMTPWriter writer = ZMTPWriter.create(ZMTP10); final ByteBuf buf = Unpooled.buffer(); writer.reset(buf); final ByteBuf f0 = copiedBuffer("hello ", UTF_8); final ByteBuf f1 = copiedBuffer("hello ",...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public final Cache buildCache(String name) throws CacheException { if (log.isDebugEnabled()) { log.debug("Loading a new EhCache cache named [" + name + "]"); } try { net.sf.ehcache.Cache cache = getCacheManager().getCach...
#fixed code public final Cache buildCache(String name) throws CacheException { if (log.isDebugEnabled()) { log.debug("Loading a new EhCache cache named [" + name + "]"); } try { net.sf.ehcache.Cache cache = getCacheManager().getCache(name...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void bindPrincipalsToSessionIfNecessary( HttpServletRequest request ) { SecurityContext ctx = (SecurityContext) ThreadContext.get( ThreadContext.SECURITY_CONTEXT_KEY ); if ( ctx != null ) { Session session = ThreadLocalSecurity...
#fixed code public static void bindPrincipalsToSessionIfNecessary( HttpServletRequest request ) { SecurityContext ctx = (SecurityContext) ThreadContext.get( ThreadContext.SECURITY_CONTEXT_KEY ); if ( ctx != null ) { Session session = ThreadLocalSecurityContex...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int onDoStartTag() throws JspException { if ( getSecurityContext().isAuthenticated() ) { return TagSupport.EVAL_BODY_INCLUDE; } else { return TagSupport.SKIP_BODY; } } #location 2 ...
#fixed code public int onDoStartTag() throws JspException { if ( getSecurityContext() != null && getSecurityContext().isAuthenticated() ) { return TagSupport.EVAL_BODY_INCLUDE; } else { return TagSupport.SKIP_BODY; } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void create( Session session ) { assignId( session ); Serializable id = session.getSessionId(); if ( id == null ) { String msg = "session must be assigned an id. Please check assignId( Session s ) " + ...
#fixed code public void create( Session session ) { Serializable id = session.getSessionId(); if ( id == null ) { String msg = "session must be assigned an id. Please check assignId( Session s ) " + "implementation."; thr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int onDoStartTag() throws JspException { String strValue = null; if( getSecurityContext().isAuthenticated() ) { // Get the principal to print out Principal principal; if( type == null ) { princ...
#fixed code public int onDoStartTag() throws JspException { String strValue = null; if( getSecurityContext() != null && getSecurityContext().isAuthenticated() ) { // Get the principal to print out Principal principal; if( type == null...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) { Session session = ThreadLocalSecurityContext.current().getSession( false ); Serializable sessionId; if( session != null ) { sessionId = session.getSe...
#fixed code public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) { Session session = (Session) ThreadContext.get( ThreadContext.SESSION_KEY ); Serializable sessionId; if( session != null ) { sessionId = session.getSessionI...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected boolean showTagBody( Permission p ) { boolean permitted = getSecurityContext().implies( p ); return !permitted; } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code protected boolean showTagBody( Permission p ) { boolean permitted = getSecurityContext() != null && getSecurityContext().implies( p ); return !permitted; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected boolean executeLogin(ServletRequest request, ServletResponse response) { if (log.isDebugEnabled()) { log.debug("Attempting to authenticate Subject based on Http BASIC Authentication request..."); } HttpServletRequest httpRe...
#fixed code protected boolean executeLogin(ServletRequest request, ServletResponse response) { if (log.isDebugEnabled()) { log.debug("Attempting to authenticate Subject based on Http BASIC Authentication request..."); } String authorizationHeader = ge...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void send( AuthenticationEvent event ) { if ( listeners != null && !listeners.isEmpty() ) { synchronized ( listeners ) { for ( AuthenticationEventListener ael : listeners ) { if ( event instanceof Successful...
#fixed code public void send( AuthenticationEvent event ) { if ( listeners != null && !listeners.isEmpty() ) { for ( AuthenticationEventListener ael : listeners ) { ael.onEvent( event ); } } else { if ( log.isWarnEnabled...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings({"unchecked"}) public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws IOException { Subject subject = getSubject(request, response); Set<String> roles = (Set<String>) mappedValue...
#fixed code @SuppressWarnings({"unchecked"}) public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws IOException { Subject subject = getSubject(request, response); String[] rolesArray = (String[]) mappedValue; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected boolean showTagBody( Permission p ) { return getSecurityContext().implies( p ); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code protected boolean showTagBody( Permission p ) { return getSecurityContext() != null && getSecurityContext().implies( p ); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void send( SessionEvent event ) { synchronized( listeners ) { for( SessionEventListener sel : listeners ) { if ( event instanceof StartedSessionEvent) { sel.sessionStarted( event ); } else if...
#fixed code public void send( SessionEvent event ) { if ( listeners != null && !listeners.isEmpty() ) { for( SessionEventListener sel : listeners ) { sel.onEvent( event ); } } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings({"unchecked"}) public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws IOException { Subject subject = getSubject(request, response); Set<String> roles = (Set<String>) mappedValue...
#fixed code @SuppressWarnings({"unchecked"}) public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws IOException { Subject subject = getSubject(request, response); String[] rolesArray = (String[]) mappedValue; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int onDoStartTag() throws JspException { if ( !getSecurityContext().isAuthenticated() ) { return TagSupport.EVAL_BODY_INCLUDE; } else { return TagSupport.SKIP_BODY; } } #location 2 ...
#fixed code public int onDoStartTag() throws JspException { if ( getSecurityContext() == null || !getSecurityContext().isAuthenticated() ) { return TagSupport.EVAL_BODY_INCLUDE; } else { return TagSupport.SKIP_BODY; } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected boolean showTagBody( String roleName ) { return getSecurityContext().hasRole( roleName ); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code protected boolean showTagBody( String roleName ) { return getSecurityContext() != null && getSecurityContext().hasRole( roleName ); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected boolean bindInHttpSessionForSubsequentRequests( HttpServletRequest request, HttpServletResponse response, SecurityContext securityContext ) { HttpSession httpSession = request.getSession(); ...
#fixed code protected boolean bindInHttpSessionForSubsequentRequests( HttpServletRequest request, HttpServletResponse response, SecurityContext securityContext ) { HttpSession httpSession = request.getSession(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected boolean showTagBody( String roleName ) { boolean hasRole = getSecurityContext().hasRole( roleName ); return !hasRole; } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code protected boolean showTagBody( String roleName ) { boolean hasRole = getSecurityContext() != null && getSecurityContext().hasRole( roleName ); return !hasRole; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testDefaultConfig() { Subject subject = SecurityUtils.getSubject(); AuthenticationToken token = new UsernamePasswordToken("guest", "guest"); subject.login(token); assertTrue(subject.isAuthenticated()); asser...
#fixed code @Test public void testDefaultConfig() { Subject subject = sm.getSubject(); AuthenticationToken token = new UsernamePasswordToken("guest", "guest"); subject.login(token); assertTrue(subject.isAuthenticated()); assertTrue("guest".equ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings( "unchecked" ) private static List<Principal> getPrincipals(HttpServletRequest request) { List<Principal> principals = null; Session session = ThreadLocalSecurityContext.current().getSession( false ); if( session != null ) ...
#fixed code @SuppressWarnings( "unchecked" ) private static List<Principal> getPrincipals(HttpServletRequest request) { List<Principal> principals = null; Session session = (Session) ThreadContext.get( ThreadContext.SESSION_KEY ); if( session != null ) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code DbAction.Insert<?> createDeepInsert(String propertyName, Object value, Object key, @Nullable DbAction.Insert<?> parentInsert) { PersistentPropertyPath<RelationalPersistentProperty> propertyPath = toPath(parentInsert.getPropertyPath().toDotPath() + "." + propertyName)...
#fixed code DbAction.Insert<?> createInsert(String propertyName, Object value, @Nullable Object key) { DbAction.Insert<Object> insert = new DbAction.Insert<>(value, context.getPersistentPropertyPath(propertyName, DummyEntity.class), rootInsert); insert.getQualifiers().put(toPath(pr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Class<?> getQualifierColumnType() { Assert.isTrue(isQualified(), "The qualifier column type is only defined for properties that are qualified"); if (isMap()) { return getTypeInformation().getComponentType().getType(); } // for lists and arra...
#fixed code @Override public Class<?> getQualifierColumnType() { Assert.isTrue(isQualified(), "The qualifier column type is only defined for properties that are qualified"); if (isMap()) { return getTypeInformation().getRequiredComponentType().getType(); } // for lists and ar...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void test() throws IOException { final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); Flowable.just("hi there".getBytes()) .compose(Transformers.outputStream(new Function<OutputStream, OutputStream>() { ...
#fixed code @Test public void test() { Flowable.just("hi there".getBytes()) .compose(Transformers.outputStream(new Function<OutputStream, OutputStream>() { @Override public OutputStream apply(OutputStream os) throws Exce...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void load() { String home = System.getProperty("user.home"); Properties awsConfigProperties = new Properties(); try { // todo: use default profile awsConfigProperties.load(new FileInputStream(home + "/.aws/config"...
#fixed code public void load() { Optional<String> region = loadRegion(); if (region.isPresent()) { this.region = region.get(); } else { this.region = DEFAULT_REGION; LOG.warn("Could not load region configuration. Please ensure ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code EntryLocation getLocationForOffset(long offset) { EntryLocation ret = new EntryLocation(); SegmentView sv = this.getSegmentForOffset(offset); long reloff = offset - sv.startoff; //select the group using a simple modulo mapping function int gnum = (int)(rel...
#fixed code SegmentView getActiveSegmentView() { return segmentlist.get(segmentlist.size()-1); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { try { observer.stopCheck(); } catch (IOException e) { observer.downloadErrored(url, "Download interrupted"); return; } if (saveAs.exists()) { if (Utils.getConfigBoolean("...
#fixed code public void run() { try { observer.stopCheck(); } catch (IOException e) { observer.downloadErrored(url, "Download interrupted"); return; } if (saveAs.exists()) { if (Utils.getConfigBoolean("file.o...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testTwitterAlbums() throws IOException { List<URL> contentURLs = new ArrayList<URL>(); //contentURLs.add(new URL("https://twitter.com/danngamber01/media")); contentURLs.add(new URL("https://twitter.com/search?q=from%3Apurrbunny%20filt...
#fixed code public void testTwitterAlbums() throws IOException { if (!DOWNLOAD_CONTENT) { return; } List<URL> contentURLs = new ArrayList<URL>(); //contentURLs.add(new URL("https://twitter.com/danngamber01/media")); contentURLs.add(new ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testTumblrAlbums() throws IOException { if (false && !DOWNLOAD_CONTENT) { return; } List<URL> contentURLs = new ArrayList<URL>(); contentURLs.add(new URL("http://wrouinr.tumblr.com/archive")); //contentURLs...
#fixed code public void testTumblrAlbums() throws IOException { if (!DOWNLOAD_CONTENT) { return; } List<URL> contentURLs = new ArrayList<URL>(); contentURLs.add(new URL("http://wrouinr.tumblr.com/archive")); contentURLs.add(new URL("htt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static List<Constructor<?>> getRipperConstructors() throws Exception { List<Constructor<?>> constructors = new ArrayList<Constructor<?>>(); String rippersPackage = "com.rarchives.ripme.ripper.rippers"; ClassLoader cl = Thread.currentThrea...
#fixed code private static List<Constructor<?>> getRipperConstructors() throws Exception { List<Constructor<?>> constructors = new ArrayList<Constructor<?>>(); for (Class<?> clazz : getClassesForPackage("com.rarchives.ripme.ripper.rippers")) { if (AbstractRipp...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testXvideosRipper() throws IOException { if (false && !DOWNLOAD_CONTENT) { return; } List<URL> contentURLs = new ArrayList<URL>(); contentURLs.add(new URL("http://www.xvideos.com/video1428195/stephanie_first_time_a...
#fixed code public void testXvideosRipper() throws IOException { if (!DOWNLOAD_CONTENT) { return; } List<URL> contentURLs = new ArrayList<URL>(); contentURLs.add(new URL("http://www.xvideos.com/video1428195/stephanie_first_time_anal")); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void downloadProblem(URL url, String message) { if (observer == null) { return; } synchronized(observer) { itemsPending.remove(url); itemsErrored.put(url, message); observer.update(this, new ...
#fixed code public void downloadProblem(URL url, String message) { if (observer == null) { return; } synchronized(observer) { itemsPending.remove(url); itemsErrored.put(url, message); observer.update(this, new RipSta...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testRedditAlbums() throws IOException { if (false && !DOWNLOAD_CONTENT) { return; } List<URL> contentURLs = new ArrayList<URL>(); //contentURLs.add(new URL("http://www.reddit.com/r/nsfw_oc")); //contentURLs...
#fixed code public void testRedditAlbums() throws IOException { if (!DOWNLOAD_CONTENT) { return; } List<URL> contentURLs = new ArrayList<URL>(); //contentURLs.add(new URL("http://www.reddit.com/r/nsfw_oc")); //contentURLs.add(new URL("h...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void login() throws IOException { File f = new File("DACookie.toDelete"); if (!f.exists()) { f.createNewFile(); f.deleteOnExit(); // Load login page Response res = Http.url("https://www.deviantart.com/users/login").connection().method(Method.GET) ...
#fixed code private void login() throws IOException { try { String dACookies = Utils.getConfigString(utilsKey, null); this.cookies = dACookies != null ? deserialize(dACookies) : null; } catch (ClassNotFoundException e) { e.printStackTrace(); } if (this.cookies == null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<String> getURLsFromPage(Document doc) { List<String> result = new ArrayList<String>(); Document userpage_doc; // We check for the following string to see if this is a user page or not if (...
#fixed code @Override public List<String> getURLsFromPage(Document doc) { List<String> result = new ArrayList<String>(); for (Element el : doc.select("a.image-container > img")) { String imageSource = el.attr("src"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { long fileSize = 0; int bytesTotal = 0; int bytesDownloaded = 0; if (saveAs.exists() && observer.tryResumeDownload()) { fileSize = saveAs.length(); } try { observer.stopCheck(); ...
#fixed code public void run() { long fileSize = 0; int bytesTotal = 0; int bytesDownloaded = 0; if (saveAs.exists() && observer.tryResumeDownload()) { fileSize = saveAs.length(); } try { observer.stopCheck(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void downloadErrored(URL url, String reason) { if (observer == null) { return; } synchronized(observer) { itemsPending.remove(url); itemsErrored.put(url, reason); observer.update(this, new Ri...
#fixed code public void downloadErrored(URL url, String reason) { if (observer == null) { return; } itemsPending.remove(url); itemsErrored.put(url, reason); observer.update(this, new RipStatusMessage(STATUS.DOWNLOAD_ERRORED, url + " : "...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test void testKeyCount() { ((ConsoleAppender) Logger.getRootLogger().getAppender("stdout")).setThreshold(Level.DEBUG); File f = new File("E:\\Downloads\\_Isaaku\\dev\\ripme-1.7.86-jar-with-dependencies.jar"); File[] files = f.listFiles(new F...
#fixed code @Test void testKeyCount() { ResourceBundle defaultBundle = Utils.getResourceBundle(null); HashMap<String, ArrayList<String>> dictionary = new HashMap<>(); for (String lang : Utils.getSupportedLanguages()) { ResourceBundle.clearCache(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String[] getDescription(String url,Document page) { if (isThisATest()) { return null; } try { // Fetch the image page Response resp = Http.url(url) .referrer...
#fixed code @Override public String[] getDescription(String url,Document page) { if (isThisATest()) { return null; } try { // Fetch the image page Response resp = Http.url(url) .referrer(this....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { long fileSize = 0; int bytesTotal = 0; int bytesDownloaded = 0; if (saveAs.exists() && observer.tryResumeDownload()) { fileSize = saveAs.length(); } try { observer.stopCheck(); ...
#fixed code public void run() { long fileSize = 0; int bytesTotal = 0; int bytesDownloaded = 0; if (saveAs.exists() && observer.tryResumeDownload()) { fileSize = saveAs.length(); } try { observer.stopCheck(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void sendUpdate(STATUS status, Object message) { if (observer == null) { return; } synchronized (observer) { observer.update(this, new RipStatusMessage(status, message)); observer.notifyAll(); } ...
#fixed code public void sendUpdate(STATUS status, Object message) { if (observer == null) { return; } observer.update(this, new RipStatusMessage(status, message)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void downloadCompleted(URL url, File saveAs) { if (observer == null) { return; } try { String path = Utils.removeCWD(saveAs); RipStatusMessage msg = new RipStatusMessage(STATUS.DOWNLOAD_COMPLETE, path); ...
#fixed code public void downloadCompleted(URL url, File saveAs) { if (observer == null) { return; } try { String path = Utils.removeCWD(saveAs); RipStatusMessage msg = new RipStatusMessage(STATUS.DOWNLOAD_COMPLETE, path); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static File getJarDirectory() { String[] classPath = System.getProperty("java.class.path").split(";"); return classPath.length > 1 ? new File(System.getProperty("user.dir")) : new File(classPath[0]).getParentFile(); } ...
#fixed code private static File getJarDirectory() { return Utils.class.getResource("/rip.properties").toString().contains("jar:") ? new File(System.getProperty("java.class.path")).getParentFile() : new File(System.getProperty("user.dir")); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<String> getURLsFromPage(Document doc) { List<String> result = new ArrayList<>(); if (getHost().contains("www.totempole666.com") || getHost().contains("buttsmithy.com") || getHost().contains("themo...
#fixed code @Override public List<String> getURLsFromPage(Document doc) { List<String> result = new ArrayList<>(); if (theme1.contains(getHost())) { Element elem = doc.select("div.comic-table > div#comic > a > img").first(); // If doc is the la...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void downloadProblem(URL url, String message) { if (observer == null) { return; } synchronized(observer) { itemsPending.remove(url); itemsErrored.put(url, message); observer.update(this, new ...
#fixed code public void downloadProblem(URL url, String message) { if (observer == null) { return; } itemsPending.remove(url); itemsErrored.put(url, message); observer.update(this, new RipStatusMessage(STATUS.DOWNLOAD_WARN, url...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void login() throws IOException { try { String dACookies = Utils.getConfigString(utilsKey, null); updateCookie(dACookies != null ? deserialize(dACookies) : null); } catch (ClassNotFoundException e) { e.printStackTrace(); } if (getDACookie() == nul...
#fixed code private void login() throws IOException { String customUsername = Utils.getConfigString("DeviantartCustomLoginUsername", this.username); String customPassword = Utils.getConfigString("DeviantartCustomLoginPassword", this.password); try { String dACookies = Utils.getCon...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testInstagramAlbums() throws IOException { List<URL> contentURLs = new ArrayList<URL>(); contentURLs.add(new URL("http://instagram.com/feelgoodincc#")); for (URL url : contentURLs) { try { InstagramRipper r...
#fixed code public void testInstagramAlbums() throws IOException { if (!DOWNLOAD_CONTENT) { return; } List<URL> contentURLs = new ArrayList<URL>(); contentURLs.add(new URL("http://instagram.com/feelgoodincc#")); for (URL url : contentUR...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void replyToStatus(String content, String replyTo) throws ArchivedGroupException, ReplyStatusException { AbstractStatus abstractOriginalStatus = statusRepository.findStatusById(replyTo); if (abstractOriginalStatus != null && !abstr...
#fixed code public void replyToStatus(String content, String replyTo) throws ArchivedGroupException, ReplyStatusException { AbstractStatus abstractStatus = statusRepository.findStatusById(replyTo); if (abstractStatus != null && !abstractStatus.getType().eq...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override @Cacheable("attachment-cache") public Attachment findAttachmentById(String attachmentId) { if (attachmentId == null) { return null; } if (log.isDebugEnabled()) { log.debug("Finding attachment : " + attach...
#fixed code @Override @Cacheable("attachment-cache") public Attachment findAttachmentById(String attachmentId) { if (attachmentId == null) { return null; } if (log.isDebugEnabled()) { log.debug("Finding attachment : " + attachmentId...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @RequestMapping(value = "/rest/statuses/{statusId}", method = RequestMethod.PATCH) @ResponseBody public StatusDTO updateStatusV3(@RequestBody ActionStatus action, @PathVariable("statusId") String statusId) { try { StatusDTO status...
#fixed code @RequestMapping(value = "/rest/statuses/{statusId}", method = RequestMethod.PATCH) @ResponseBody public StatusDTO updateStatusV3(@RequestBody ActionStatus action, @PathVariable("statusId") String statusId) { try { StatusDTO status = tim...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void replyToStatus(String content, String replyTo) throws ArchivedGroupException { Status originalStatus = statusRepository.findStatusById(replyTo); Group group = null; if (originalStatus.getGroupId() != null) { group = groupSe...
#fixed code public void replyToStatus(String content, String replyTo) throws ArchivedGroupException { Status originalStatus = statusRepository.findStatusById(replyTo); Group group = null; if (originalStatus.getGroupId() != null) { group = groupService....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public T borrowObject(K key, long borrowMaxWait) throws Exception { assertOpen(); PooledObject<T> p = null; // Get local copy of current config so it is consistent for entire // method execution boolean blockWhenExhausted = thi...
#fixed code public T borrowObject(K key, long borrowMaxWait) throws Exception { assertOpen(); PooledObject<T> p = null; // Get local copy of current config so it is consistent for entire // method execution boolean blockWhenExhausted = getBlockW...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setFactory(KeyedPoolableObjectFactory factory) throws IllegalStateException { Map toDestroy = new HashMap(); synchronized (this) { assertOpen(); if (0 < getNumActive()) { throw new IllegalStateException...
#fixed code public void setFactory(KeyedPoolableObjectFactory factory) throws IllegalStateException { Map toDestroy = new HashMap(); final KeyedPoolableObjectFactory oldFactory = _factory; synchronized (this) { assertOpen(); if (0 < getNumA...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object borrowObject() throws Exception { long starttime = System.currentTimeMillis(); Latch latch = new Latch(); synchronized (this) { _allocationQueue.add(latch); allocate(); } for(;;) { ...
#fixed code public Object borrowObject() throws Exception { long starttime = System.currentTimeMillis(); Latch latch = new Latch(); byte whenExhaustedAction; long maxWait; synchronized (this) { // Get local copy of current config. Can't...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object borrowObject(Object key) throws Exception { long starttime = System.currentTimeMillis(); Latch latch = new Latch(key); synchronized (this) { _allocationQueue.add(latch); allocate(); } ...
#fixed code public Object borrowObject(Object key) throws Exception { long starttime = System.currentTimeMillis(); Latch latch = new Latch(key); byte whenExhaustedAction; long maxWait; synchronized (this) { // Get local copy of current ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void addObject(Object key) throws Exception { assertOpen(); if (_factory == null) { throw new IllegalStateException("Cannot add objects without a factory."); } Object obj = _factory.makeObject(key); synchronized...
#fixed code public void addObject(Object key) throws Exception { assertOpen(); if (_factory == null) { throw new IllegalStateException("Cannot add objects without a factory."); } Object obj = _factory.makeObject(key); try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void clear(Object key) { Map toDestroy = new HashMap(); final ObjectQueue pool; synchronized (this) { pool = (ObjectQueue)(_poolMap.remove(key)); if (pool == null) { return; } else { ...
#fixed code public void clear(Object key) { Map toDestroy = new HashMap(); final ObjectQueue pool; synchronized (this) { pool = (ObjectQueue)(_poolMap.remove(key)); if (pool == null) { return; } else { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object borrowObject(Object key) throws Exception { long starttime = System.currentTimeMillis(); Latch latch = new Latch(key); synchronized (this) { _allocationQueue.add(latch); allocate(); } ...
#fixed code public Object borrowObject(Object key) throws Exception { long starttime = System.currentTimeMillis(); Latch latch = new Latch(key); byte whenExhaustedAction; long maxWait; synchronized (this) { // Get local copy of current ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void clearOldest() { // Map of objects to destroy my key final Map toDestroy = new HashMap(); // build sorted map of idle objects final Map map = new TreeMap(); synchronized (this) { for (Iterator keyiter = _po...
#fixed code public void clearOldest() { // Map of objects to destroy my key final Map toDestroy = new HashMap(); // build sorted map of idle objects final Map map = new TreeMap(); synchronized (this) { for (Iterator keyiter = _poolMap....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public long getIdleTimeMillis() { return System.currentTimeMillis() - lastActiveTime; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public long getIdleTimeMillis() { return System.currentTimeMillis() - lastReturnTime; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void clear() { List toDestroy = new ArrayList(); synchronized(this) { toDestroy.addAll(_pool); _numInternalProcessing = _numInternalProcessing + _pool._size; _pool.clear(); } destroy(toDestroy);...
#fixed code public void clear() { List toDestroy = new ArrayList(); synchronized(this) { toDestroy.addAll(_pool); _numInternalProcessing = _numInternalProcessing + _pool._size; _pool.clear(); } destroy(toDestroy, _facto...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void evict() throws Exception { assertOpen(); if (getNumIdle() == 0) { return; } boolean testWhileIdle = getTestWhileIdle(); long idleEvictTime = Long.MAX_VALUE; if (getMinEvictableIdleTimeMi...
#fixed code public void evict() throws Exception { assertOpen(); if (getNumIdle() == 0) { return; } synchronized (evictionLock) { boolean testWhileIdle = getTestWhileIdle(); long idleEvictTime = Long.MAX_VALUE; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public T borrowObject(K key, long borrowMaxWait) throws Exception { assertOpen(); PooledObject<T> p = null; // Get local copy of current config so it is consistent for entire // method execution boolean blockWhenExhausted = get...
#fixed code public T borrowObject(K key, long borrowMaxWait) throws Exception { assertOpen(); PooledObject<T> p = null; // Get local copy of current config so it is consistent for entire // method execution boolean blockWhenExhausted = getBlockW...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void evict() throws Exception { assertOpen(); synchronized (this) { if(_pool.isEmpty()) { return; } if (null == _evictionCursor) { _evictionCursor = (_pool.cursor(_lifo ? _pool.si...
#fixed code public void evict() throws Exception { assertOpen(); if (_pool.size() == 0) { return; } PooledObject<T> underTest = null; for (int i = 0, m = getNumTests(); i < m; i++) { if (_evictionIterator ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void evict() throws Exception { // Initialize key to last key value Object key = null; synchronized (this) { if (_evictionKeyCursor != null && _evictionKeyCursor._lastReturned != null) { key...
#fixed code public void evict() throws Exception { Object key = null; boolean testWhileIdle; long minEvictableIdleTimeMillis; synchronized (this) { // Get local copy of current config. Can't sync when used later as // it ca...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void evict() throws Exception { assertOpen(); if (getNumIdle() == 0) { return; } boolean testWhileIdle = getTestWhileIdle(); long idleEvictTime = Long.MAX_VALUE; if (getMinEvictableIdleTimeMi...
#fixed code public void evict() throws Exception { assertOpen(); if (getNumIdle() == 0) { return; } synchronized (evictionLock) { boolean testWhileIdle = getTestWhileIdle(); long idleEvictTime = Long.MAX_VALUE; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public long getActiveTimeMillis() { if (lastReturnTime > lastBorrowTime) { return lastReturnTime - lastBorrowTime; } else { return System.currentTimeMillis() - lastBorrowTime; } } #location...
#fixed code public long getActiveTimeMillis() { // Take copies to avoid threading issues long rTime = lastReturnTime; long bTime = lastBorrowTime; if (rTime > bTime) { return rTime - bTime; } else { return System.cu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setFactory(PoolableObjectFactory factory) throws IllegalStateException { List toDestroy = new ArrayList(); synchronized (this) { assertOpen(); if(0 < getNumActive()) { throw new IllegalStateException("O...
#fixed code public void setFactory(PoolableObjectFactory factory) throws IllegalStateException { List toDestroy = new ArrayList(); final PoolableObjectFactory oldFactory = _factory; synchronized (this) { assertOpen(); if(0 < getNumActive())...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public T borrowObject(K key, long borrowMaxWait) throws Exception { assertOpen(); PooledObject<T> p = null; // Get local copy of current config so it is consistent for entire // method execution boolean blockWhenExhausted = getB...
#fixed code public T borrowObject(K key, long borrowMaxWait) throws Exception { assertOpen(); PooledObject<T> p = null; // Get local copy of current config so it is consistent for entire // method execution boolean blockWhenExhausted = getBlockWh...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void evict() throws Exception { assertOpen(); synchronized (this) { if(_pool.isEmpty()) { return; } if (null == _evictionCursor) { _evictionCursor = (_pool.cursor(_lifo ? _pool.si...
#fixed code public void evict() throws Exception { assertOpen(); if (_pool.size() == 0) { return; } PooledObject<T> underTest = null; for (int i = 0, m = getNumTests(); i < m; i++) { if (_evictionIterator ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void clear() { Map toDestroy = new HashMap(); synchronized (this) { for (Iterator it = _poolMap.keySet().iterator(); it.hasNext();) { Object key = it.next(); ObjectQueue pool = (ObjectQueue)_poolMap.get(...
#fixed code public void clear() { Map toDestroy = new HashMap(); synchronized (this) { for (Iterator it = _poolMap.keySet().iterator(); it.hasNext();) { Object key = it.next(); ObjectQueue pool = (ObjectQueue)_poolMap.get(key); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void printStackTrace(PrintWriter writer) { if (borrowedBy != null) { borrowedBy.printStackTrace(writer); } if (usedBy != null) { usedBy.printStackTrace(writer); } } ...
#fixed code @Override public void printStackTrace(PrintWriter writer) { Exception borrowedBy = this.borrowedBy; if (borrowedBy != null) { borrowedBy.printStackTrace(writer); } Exception usedBy = this.usedBy; if (usedBy != null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void evict() throws Exception { assertOpen(); if (getNumIdle() == 0) { return; } boolean testWhileIdle = getTestWhileIdle(); long idleEvictTime = Long.MAX_VALUE; if (getMinEvictableIdleTimeMi...
#fixed code public void evict() throws Exception { assertOpen(); if (getNumIdle() == 0) { return; } synchronized (evictionLock) { boolean testWhileIdle = getTestWhileIdle(); long idleEvictTime = Long.MAX_VALUE; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void evict() throws Exception { // Initialize key to last key value Object key = null; synchronized (this) { if (_evictionKeyCursor != null && _evictionKeyCursor._lastReturned != null) { key...
#fixed code public void evict() throws Exception { Object key = null; boolean testWhileIdle; long minEvictableIdleTimeMillis; synchronized (this) { // Get local copy of current config. Can't sync when used later as // it ca...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public long getActiveTimeMillis() { if (lastReturnTime > lastBorrowTime) { return lastReturnTime - lastBorrowTime; } else { return System.currentTimeMillis() - lastBorrowTime; } } #location...
#fixed code public long getActiveTimeMillis() { // Take copies to avoid threading issues long rTime = lastReturnTime; long bTime = lastBorrowTime; if (rTime > bTime) { return rTime - bTime; } else { return System.cu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void destroy(Map m, KeyedPoolableObjectFactory factory) { for (Iterator keys = m.keySet().iterator(); keys.hasNext();) { Object key = keys.next(); Collection c = (Collection) m.get(key); for (Iterator it = c.iterator()...
#fixed code private void destroy(Map m, KeyedPoolableObjectFactory factory) { for (Iterator entries = m.entrySet().iterator(); entries.hasNext();) { Map.Entry entry = (Entry) entries.next(); Object key = entry.getKey(); Collection c = (Collecti...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void evict() throws Exception { // Initialize key to last key value Object key = null; synchronized (this) { if (_evictionKeyCursor != null && _evictionKeyCursor._lastReturned != null) { key...
#fixed code public void evict() throws Exception { Object key = null; boolean testWhileIdle; long minEvictableIdleTimeMillis; synchronized (this) { // Get local copy of current config. Can't sync when used later as // it ca...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int compareTo(PooledObject<T> other) { final long lastActiveDiff = this.getLastActiveTime() - other.getLastActiveTime(); if (lastActiveDiff == 0) { // make sure the natural ordering is consistent with equals ...
#fixed code public int compareTo(PooledObject<T> other) { final long lastActiveDiff = this.getLastReturnTime() - other.getLastReturnTime(); if (lastActiveDiff == 0) { // make sure the natural ordering is consistent with equals // se...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public T borrowObject(K key, long borrowMaxWait) throws Exception { assertOpen(); PooledObject<T> p = null; // Get local copy of current config so it is consistent for entire // method execution boolean blockWhenExhausted = get...
#fixed code public T borrowObject(K key, long borrowMaxWait) throws Exception { assertOpen(); PooledObject<T> p = null; // Get local copy of current config so it is consistent for entire // method execution boolean blockWhenExhausted = getBlockW...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object borrowObject() throws Exception { long starttime = System.currentTimeMillis(); Latch latch = new Latch(); synchronized (this) { _allocationQueue.add(latch); allocate(); } for(;;) { ...
#fixed code public Object borrowObject() throws Exception { long starttime = System.currentTimeMillis(); Latch latch = new Latch(); byte whenExhaustedAction; long maxWait; synchronized (this) { // Get local copy of current config. Can't...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void evict() throws Exception { assertOpen(); if (getNumIdle() == 0) { return; } boolean testWhileIdle = getTestWhileIdle(); long idleEvictTime = Long.MAX_VALUE; if (getMinEvictableIdleTimeMi...
#fixed code public void evict() throws Exception { assertOpen(); if (getNumIdle() == 0) { return; } synchronized (evictionLock) { boolean testWhileIdle = getTestWhileIdle(); long idleEvictTime = Long.MAX_VALUE; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean process(Set<? extends TypeElement> type, RoundEnvironment env) { Elements elementUtils = processingEnv.getElementUtils(); Types typeUtils = processingEnv.getTypeUtils(); Filer filer = processingEnv.getFiler(); // // Process...
#fixed code @Override public boolean process(Set<? extends TypeElement> type, RoundEnvironment env) { Elements elementUtils = processingEnv.getElementUtils(); Types typeUtils = processingEnv.getTypeUtils(); Filer filer = processingEnv.getFiler(); // // Processor opt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean process(Set<? extends TypeElement> type, RoundEnvironment env) { Types typeUtils = processingEnv.getTypeUtils(); Filer filer = processingEnv.getFiler(); // // Processor options // boolean isL...
#fixed code @Override public boolean process(Set<? extends TypeElement> type, RoundEnvironment env) { Types typeUtils = processingEnv.getTypeUtils(); Filer filer = processingEnv.getFiler(); // // Processor options // boolean isLibrary...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testMissingSlotMillis() throws IOException { final String JOB_HISTORY_FILE_NAME = "src/test/resources/job_1329348432999_0003-1329348443227-user-Sleep+job-1329348468601-10-1-SUCCEEDED-default.jhist"; File jobHistoryfile = new File(JOB_H...
#fixed code @Test public void testMissingSlotMillis() throws IOException { final String JOB_HISTORY_FILE_NAME = "src/test/resources/job_1329348432999_0003-1329348443227-user-Sleep+job-1329348468601-10-1-SUCCEEDED-default.jhist"; File jobHistoryfile = new File(JOB_HISTORY...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFlowQueueReadWrite() throws Exception { FlowQueueService service = new FlowQueueService(UTIL.getConfiguration()); // add a couple of test flows FlowQueueKey key1 = new FlowQueueKey(TEST_CLUSTER, Flow.Status.RUNNING, System.curr...
#fixed code @Test public void testFlowQueueReadWrite() throws Exception { FlowQueueService service = new FlowQueueService(UTIL.getConfiguration()); // add a couple of test flows Flow flow1 = createFlow(service, TEST_USER, 1); FlowQueueKey key1 = flow1.getQueueKey(); ...
Below is the vulnerable code, please generate the patch based on the following information.