auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected String getPattern(int groupOffset) { <START> return "(&[A-Za-z]+;)"; END> }</code><technical_language>Consider limiting number of characters 32, HTML entities more characters avoid false-positive matches. <LINK_0></technical_language>

Target:
protected String getPattern(int groupOffset) { return "(&[A-Za-z]{1,32}+;)"; }
Source:
<code>private synchronized void initConnectStatusCheckCommand() { int reconnect = getReconnectParam(getUrl()); if (reconnect > 0 && (reconnectExecutorFuture == null || reconnectExecutorFuture.isCancelled())) { Runnable connectStatusCheckCommand = new Runnable() { @Override public void run() { try { <START> if (cancelFutureIfOffline()) return; <END> if (!isConnected()) { connect(); } else { lastConnectedTime = System.currentTimeMillis(); } } catch (Throwable t) { String errorMsg = "client reconnect to " + getUrl().getAddress() + " find error . url: " + getUrl(); if (System.currentTimeMillis() - lastConnectedTime > shutdown_timeout) { if (!reconnect_error_log_flag.get()) { reconnect_error_log_flag.set(true); logger.error(errorMsg, t); return; } } if (reconnect_count.getAndIncrement() % reconnect_warning_period == 0) { logger.warn(errorMsg, t); } } } private boolean cancelFutureIfOffline() { if(isClosed()) { ScheduledFuture<?> future = reconnectExecutorFuture; if(future != null && !future.isCancelled()){ future.cancel(true); } return true; } return false; } }; reconnectExecutorFuture = reconnectExecutorService.scheduleWithFixedDelay(connectStatusCheckCommand, reconnect, reconnect, TimeUnit.MILLISECONDS); } }</code><technical_language>considered Increase readability</technical_language>

Target:
private synchronized void initConnectStatusCheckCommand() { int reconnect = getReconnectParam(getUrl()); if (reconnect > 0 && (reconnectExecutorFuture == null || reconnectExecutorFuture.isCancelled())) { Runnable connectStatusCheckCommand = new Runnable() { @Override public void run() { try { if (cancelFutureIfOffline()) { return; } if (!isConnected()) { connect(); } else { lastConnectedTime = System.currentTimeMillis(); } } catch (Throwable t) { String errorMsg = "client reconnect to " + getUrl().getAddress() + " find error . url: " + getUrl(); if (System.currentTimeMillis() - lastConnectedTime > shutdown_timeout) { if (!reconnect_error_log_flag.get()) { reconnect_error_log_flag.set(true); logger.error(errorMsg, t); return; } } if (reconnect_count.getAndIncrement() % reconnect_warning_period == 0) { logger.warn(errorMsg, t); } } } private boolean cancelFutureIfOffline() { if(isClosed()) { ScheduledFuture<?> future = reconnectExecutorFuture; if(future != null && !future.isCancelled()){ future.cancel(true); } return true; } return false; } }; reconnectExecutorFuture = reconnectExecutorService.scheduleWithFixedDelay(connectStatusCheckCommand, reconnect, reconnect, TimeUnit.MILLISECONDS); } }
Source:
<code>public Rule Query() { <START> return Sequence( Optional( QueryCliOrSimple() ), push( builder ) ); <END> }</code><technical_language>a bit puzzled this change, especially Optional? is support returning error for empty queries</technical_language>

Target:
public Rule Query() { return Sequence( push( new MongoDBQueryDescriptorBuilder() ), Optional( CliQueryOrJsonFindQuery() ) ); }
Source:
<code>public void hasSameOrderableAs_shouldReturnFalseIfTheConceptsMatchAndHaveDifferentDrugNonCoded() throws Exception { DrugOrder order = new DrugOrder(); Concept concept = new Concept(); <START> order.setDrugNonCoded("Chrocine"); <END> DrugOrder otherOrder = new DrugOrder(); otherOrder.setConcept(concept); otherOrder.setDrugNonCoded("paracetemol"); assertFalse(order.hasSameOrderableAs(otherOrder)); }</code><technical_language>forgot set concept this order</technical_language>

Target:
public void hasSameOrderableAs_shouldReturnFalseIfTheConceptsMatchAndHaveDifferentDrugNonCoded() throws Exception { DrugOrder order = new DrugOrder(); Concept concept = new Concept(); order.setConcept(concept); order.setDrugNonCoded("Chrocine"); DrugOrder otherOrder = new DrugOrder(); otherOrder.setConcept(concept); otherOrder.setDrugNonCoded("paracetemol"); assertFalse(order.hasSameOrderableAs(otherOrder)); }
Source:
<code>protected void assertNoService(String serviceName, IType parameterTypes[]) { final IService service = serviceLookUp(serviceName, parameterTypes); <START> assertTrue(service == null); <END> }</code><technical_language>assertNull</technical_language>

Target:
protected void assertNoService(String serviceName, IType parameterTypes[]) { final IService service = serviceLookUp(serviceName, parameterTypes); assertNull(service); }
Source:
<code>public static int getMaxHttpConnectionsPerHost() { <START> return getSystemPropertyAndParseInt("org.eclipse.mylyn.commons.http.connections.per.host", <END> MAX_HTTP_HOST_CONNECTIONS); }</code><technical_language>I guess declared constants somewhere</technical_language>

Target:
public static int getMaxHttpConnectionsPerHost() { return getSystemPropertyAndParseInt(MAX_HTTP_HOST_CONNECTIONS_PROPERTY, MAX_HTTP_HOST_CONNECTIONS_DEFAULT); }
Source:
<code>private Times saveTimes(){ if(isTestingSTO) { delays.remove(); Times times = new Times(delayBeforeSTOFlag, delayAfterBuildingTree); delays.set(times); return times; } <START> throw new UnsupportedOperationException("Operation only supported for testing"); <END> }</code><technical_language>Save time is called in a lot of place checking if is a test, this breaks a lot of tests</technical_language>

Target:
private Times saveTimes(){ if(isTestingSTO) { delays.remove(); Times times = new Times(delayBeforeSTOFlag, delayAfterBuildingTree); delays.set(times); return times; }else{ return null; } }
Source:
<code>public static Launcher create(LauncherConfig config) throws PreconditionViolationException { Preconditions.notNull(config, "LauncherConfig must not be null"); Set<TestEngine> engines = new LinkedHashSet<>(); if (config.isTestEngineAutoRegistrationEnabled()) { new ServiceLoaderTestEngineRegistry().loadTestEngines().forEach(engines::add); } engines.addAll(config.getAdditionalTestEngines()); <START> Set<PostDiscoveryFilter> filters = new LinkedHashSet<>(); <END> if (config.isPostDiscoveryFilterAutoRegistrationEnabled()) { new ServiceLoaderPostDiscoveryFilterRegistry().loadPostDiscoveryFilters().forEach(filters::add); } filters.addAll(config.getAdditionalPostDiscoveryFilters()); Launcher launcher = new DefaultLauncher(engines, filters); if (config.isTestExecutionListenerAutoRegistrationEnabled()) { loadAndFilterTestExecutionListeners().forEach(launcher::registerTestExecutionListeners); } config.getAdditionalTestExecutionListeners().forEach(launcher::registerTestExecutionListeners); return launcher; }</code><technical_language>a Set consistent engines above. Thoughts</technical_language>

Target:
public static Launcher create(LauncherConfig config) throws PreconditionViolationException { Preconditions.notNull(config, "LauncherConfig must not be null"); Set<TestEngine> engines = new LinkedHashSet<>(); if (config.isTestEngineAutoRegistrationEnabled()) { new ServiceLoaderTestEngineRegistry().loadTestEngines().forEach(engines::add); } engines.addAll(config.getAdditionalTestEngines()); List<PostDiscoveryFilter> filters = new ArrayList<>(); if (config.isPostDiscoveryFilterAutoRegistrationEnabled()) { new ServiceLoaderPostDiscoveryFilterRegistry().loadPostDiscoveryFilters().forEach(filters::add); } filters.addAll(config.getAdditionalPostDiscoveryFilters()); Launcher launcher = new DefaultLauncher(engines, filters); if (config.isTestExecutionListenerAutoRegistrationEnabled()) { loadAndFilterTestExecutionListeners().forEach(launcher::registerTestExecutionListeners); } config.getAdditionalTestExecutionListeners().forEach(launcher::registerTestExecutionListeners); return launcher; }
Source:
<code>private void addJUnitMethodSourceValues(SimpleSetOfCharArray junitMethodSourceValues, Annotation annotation, char[] methodName) { for (MemberValuePair memberValuePair : annotation.memberValuePairs()) { if (CharOperation.equals(memberValuePair.name, TypeConstants.VALUE)) { Expression value = memberValuePair.value; if (value instanceof ArrayInitializer) { ArrayInitializer arrayInitializer = (ArrayInitializer) value; for (Expression arrayValue : arrayInitializer.expressions) { junitMethodSourceValues.add(getValueAsChars(arrayValue)); } } else { junitMethodSourceValues.add(getValueAsChars(value)); } } } <START> junitMethodSourceValues.add(methodName); <END> }</code><technical_language>this is executed values present, wrong me</technical_language>

Target:
private void addJUnitMethodSourceValues(SimpleSetOfCharArray junitMethodSourceValues, Annotation annotation, char[] methodName) { for (MemberValuePair memberValuePair : annotation.memberValuePairs()) { if (CharOperation.equals(memberValuePair.name, TypeConstants.VALUE)) { Expression value = memberValuePair.value; if (value instanceof ArrayInitializer) { ArrayInitializer arrayInitializer = (ArrayInitializer) value; for (Expression arrayValue : arrayInitializer.expressions) { junitMethodSourceValues.add(getValueAsChars(arrayValue)); } } else { junitMethodSourceValues.add(getValueAsChars(value)); } return; } } junitMethodSourceValues.add(methodName); }
Source:
<code><START> public RadiologyReport() { <END> }</code><technical_language>this anywhere? if not, remove it</technical_language>

Target:
protected RadiologyReport() { }
Source:
<code>public Response intercept(Chain chain) throws IOException { Request request = chain.request(); Connection connection = chain.connection(); <START> if (connection == null) { END> String name = tagIsLocalSpanName && !(request.tag() instanceof Request) ? request.tag().toString() : spanName.spanName(new OkHttpRequest(request)); SpanId spanId = brave.localTracer().startNewSpan("okhttp", name); if (spanId == null) request = request.newBuilder().addHeader(Sampled.getName(), "0").build(); try { return chain.proceed(request); } catch (IOException | RuntimeException | Error e) { brave.localTracer().submitBinaryAnnotation(Constants.ERROR, e.getMessage()); throw e; } finally { brave.localTracer().finishSpan(); } } else { return traceRequest(chain, request, connection); } }</code><technical_language>Neat. a single interceptor work in modes, sense</technical_language>

Target:
public Response intercept(Chain chain) throws IOException { Connection connection = chain.connection(); boolean applicationRequest = connection == null; Request request = chain.request(); SpanId spanId; if (applicationRequest) { spanId = localTracer.startNewSpan("okhttp", parser.applicationSpanName(request)); } else { spanId = clientTracer.startNewSpan(parser.networkSpanName(request)); } if (spanId == null) { return applicationRequest ? chain.proceed(request) : chain.proceed(request.newBuilder().header(Sampled.getName(), "0").build()); } else if (applicationRequest) { return traceApplicationRequest(chain, request); } else { Request tracedRequest = addTraceHeaders(request, spanId).build(); return traceNetworkRequest(chain, tracedRequest); } }
Source:
<code><START> public void bogusDataTest() throws Exception { <END> Socket socket = new Socket(); socket.connect(new InetSocketAddress(HostUtil.getHostName(), config.getOraclePort())); OutputStream outstream = socket .getOutputStream(); PrintWriter out = new PrintWriter(outstream); out.print("abcd"); out.flush(); socket.close(); OracleClient client = OracleClient.getInstance(config); assertEquals(2, client.getTimestamp()); }</code><technical_language>this test produces this error message shows Thrift is catching bogus input. Correct? 2014-07-30 17:03:45,306 [server.THsHaServer] ERROR: Read a frame size of 1633837924, is bigger maximum allowable buffer size for connections. If this error message is expected, I temporarily upping log level for test code creates issue for this error message. java Logger.getRootLogger().setLevel(Level.FATAL); // test code generates error message Logger.getRootLogger().setLevel(Level.INFO);</technical_language>

Target:
public void bogusDataTest() throws Exception { Level curLevel = Logger.getLogger(THsHaServer.class).getLevel(); Logger.getLogger(THsHaServer.class).setLevel(Level.FATAL); Socket socket = new Socket(); socket.connect(new InetSocketAddress(HostUtil.getHostName(), config.getOraclePort())); OutputStream outstream = socket .getOutputStream(); PrintWriter out = new PrintWriter(outstream); out.print("abcd"); out.flush(); socket.close(); OracleClient client = OracleClient.getInstance(config); assertEquals(2, client.getTimestamp()); Logger.getLogger(THsHaServer.class).setLevel(curLevel); }
Source:
<code>public String completeToolTipText(String toolTipText, EObject eObject, EStructuralFeature feature) { String toolTip = toolTipText; Option<EObject> parentRepresentationDescription = new EObjectQuery(eObject).getFirstAncestorOfType(DescriptionPackage.eINSTANCE.getRepresentationDescription()); if (parentRepresentationDescription.some()) { for (final DialectUI dialect : dialects.values()) { if (dialect.getServices().canHandle((RepresentationDescription) parentRepresentationDescription.get())) { toolTip = dialect.getServices().completeToolTipText(toolTipText, eObject, feature); } } } else { Option<EObject> parentRepresentationExtensionDescription = new EObjectQuery(eObject).getFirstAncestorOfType(DescriptionPackage.eINSTANCE.getRepresentationExtensionDescription()); if (parentRepresentationDescription.some()) { for (final DialectUI dialect : dialects.values()) { if (dialect.getServices().canHandle((RepresentationExtensionDescription) parentRepresentationExtensionDescription.get())) { toolTip = <START> dialect.getServices().completeToolTipText(toolTipText, <END> eObject); } } } } return toolTip; }</code><technical_language>new api too</technical_language>

Target:
public String completeToolTipText(String toolTipText, EObject eObject, EStructuralFeature feature) { String toolTip = toolTipText; Option<EObject> parentRepresentationDescription = new EObjectQuery(eObject).getFirstAncestorOfType(DescriptionPackage.eINSTANCE.getRepresentationDescription()); if (parentRepresentationDescription.some()) { for (final DialectUI dialect : dialects.values()) { if (dialect.getServices().canHandle((RepresentationDescription) parentRepresentationDescription.get())) { toolTip = dialect.getServices().completeToolTipText(toolTipText, eObject, feature); } } } else { Option<EObject> parentRepresentationExtensionDescription = new EObjectQuery(eObject).getFirstAncestorOfType(DescriptionPackage.eINSTANCE.getRepresentationExtensionDescription()); if (parentRepresentationDescription.some()) { for (final DialectUI dialect : dialects.values()) { if (dialect.getServices().canHandle((RepresentationExtensionDescription) parentRepresentationExtensionDescription.get())) { toolTip = dialect.getServices().completeToolTipText(toolTipText, eObject, feature); } } } } return toolTip; }
Source:
<code><START> public void resetPassword(Users p, String pass) throws Exception { <END> List<Project> projects = projectFacade.findByUser(p); List<UserCerts> oldCerts = userCertsFacade.findUserCertsByUid(p.getUsername()); try { for (Project project : projects) { UserCerts userCert = userCertsFacade.findUserCert(project.getName(), p.getUsername()); String certPassword = HopsUtils.decrypt(p.getPassword(), userCert.getUserKeyPwd()); String newSecret = HopsUtils.encrypt(pass, certPassword); userCert.setUserKeyPwd(newSecret); userCertsFacade.persist(userCert); } p.setPassword(pass); p.setPasswordChanged(new Timestamp(new Date().getTime())); em.merge(p); } catch (Exception ex) { Logger.getLogger(UserManager.class.getName()).log(Level.SEVERE, null, ex); for (UserCerts oldCert : oldCerts) { userCertsFacade.persist(oldCert); } throw new Exception(ex); } }</code><technical_language>If user is owner of a project update project generic certificate's password</technical_language>

Target:
public void resetPassword(Users p, String pass) throws Exception { List<Project> projects = projectFacade.findAllMemberStudies(p); List<UserCerts> oldCerts = userCertsFacade.findUserCertsByUid(p.getUsername()); List<ProjectGenericUserCerts> pguCerts = null; try { for (Project project : projects) { UserCerts userCert = userCertsFacade.findUserCert(project.getName(), p.getUsername()); String certPassword = HopsUtils.decrypt(p.getPassword(), userCert.getUserKeyPwd()); String newSecret = HopsUtils.encrypt(pass, certPassword); userCert.setUserKeyPwd(newSecret); userCertsFacade.persist(userCert); if (project.getOwner().equals(p)) { if (pguCerts == null) { pguCerts = new ArrayList<>(); } ProjectGenericUserCerts pguCert = userCertsFacade.findProjectGenericUserCerts(project.getName() + Settings.PROJECT_GENERIC_USER_SUFFIX); pguCerts.add(userCertsFacade.findProjectGenericUserCerts(project.getName() + Settings.PROJECT_GENERIC_USER_SUFFIX)); String pguCertPassword = HopsUtils.decrypt(p.getPassword(), pguCert.getCertificatePassword()); String newPguSecret = HopsUtils.encrypt(pass, pguCertPassword); pguCert.setCertificatePassword(newPguSecret); userCertsFacade.persistPGUCert(pguCert); } } p.setPassword(pass); p.setPasswordChanged(new Timestamp(new Date().getTime())); em.merge(p); } catch (Exception ex) { Logger.getLogger(UserManager.class.getName()).log(Level.SEVERE, null, ex); for (UserCerts oldCert : oldCerts) { userCertsFacade.persist(oldCert); } if (pguCerts != null) { for (ProjectGenericUserCerts pguCert : pguCerts) { userCertsFacade.persistPGUCert(pguCert); } } throw new Exception(ex); } }
Source:
<code>public SavedSearch getSavedSearch(CoreSession session, String id) { DocumentRef docRef = new IdRef(id); DocumentModel savedSearchDoc = session.getDocument(docRef); if (savedSearchDoc != null) { <START> SavedSearch search = savedSearchDoc.getAdapter(SavedSearch.class); <END> if (search != null) { return search; } } return null; }</code><technical_language>return here</technical_language>

Target:
public SavedSearch getSavedSearch(CoreSession session, String id) { DocumentRef docRef = new IdRef(id); DocumentModel savedSearchDoc = session.getDocument(docRef); if (savedSearchDoc != null) { return savedSearchDoc.getAdapter(SavedSearch.class); } return null; }
Source:
<code>public ColumnStatistics withBloomFilter(HiveBloomFilter bloomFilter) { return new ColumnStatistics( <START> hasNumberOfValues() ? numberOfValues : null, <END> minAverageValueSizeInBytes, booleanStatistics, integerStatistics, doubleStatistics, stringStatistics, dateStatistics, decimalStatistics, binaryStatistics, bloomFilter); }</code><technical_language>depending change above, this getNumberOfValues()</technical_language>

Target:
public ColumnStatistics withBloomFilter(HiveBloomFilter bloomFilter) { return new ColumnStatistics( getNumberOfValues(), minAverageValueSizeInBytes, booleanStatistics, integerStatistics, doubleStatistics, stringStatistics, dateStatistics, decimalStatistics, binaryStatistics, bloomFilter); }
Source:
<code><START> static NationalAppealChamberJudgment createSimpleNacJudgment(){ <END> NationalAppealChamberJudgment judgment = new NationalAppealChamberJudgment(); judgment.addCourtCase(new CourtCase(RandomStringUtils.randomAlphanumeric(10))); judgment.getSourceInfo().setSourceCode(SourceCode.NATIONAL_APPEAL_CHAMBER); judgment.getSourceInfo().setSourceJudgmentId(RandomStringUtils.randomAlphabetic(20)); return judgment; }</code><technical_language>public</technical_language>

Target:
public static NationalAppealChamberJudgment createSimpleNacJudgment(){ NationalAppealChamberJudgment judgment = new NationalAppealChamberJudgment(); judgment.addCourtCase(new CourtCase(RandomStringUtils.randomAlphanumeric(10))); judgment.getSourceInfo().setSourceCode(SourceCode.NATIONAL_APPEAL_CHAMBER); judgment.getSourceInfo().setSourceJudgmentId(RandomStringUtils.randomAlphabetic(20)); return judgment; }
Source:
<code>public void close() throws Exception { <START> metricsMgrClient.stop(); <END> looper.exitLoop(); outMetricsQueues.clear(); }</code><technical_language>safer in this order? looper.exitLoop(); metricsMgrClient.stop(); outMetricsQueues.clear();</technical_language>

Target:
public void close() throws Exception { looper.exitLoop(); metricsMgrClient.stop(); outMetricsQueues.clear(); }
Source:
<code>public void getFromPoint(RotatedTileBox tb,PointF point, List<? super TransportStop> res) { if (objects != null) { int ex = (int) point.x; int ey = (int) point.y; final int rp = getRadiusPoi(tb); int radius = rp * 3 / 2; int small = rp; try { for (int i = 0; i < objects.size(); i++) { TransportStop n = objects.get(i); if (n.getLocation() == null){ <START> return; <END> } int x = (int) tb.getPixXFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude()); int y = (int) tb.getPixYFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude()); if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) { radius = small; res.add(n); } } } catch (IndexOutOfBoundsException e) { } } }</code><technical_language>continue; !!</technical_language>

Target:
public void getFromPoint(RotatedTileBox tb,PointF point, List<? super TransportStop> res) { if (objects != null) { int ex = (int) point.x; int ey = (int) point.y; final int rp = getRadiusPoi(tb); int radius = rp * 3 / 2; int small = rp; try { for (int i = 0; i < objects.size(); i++) { TransportStop n = objects.get(i); if (n.getLocation() == null){ continue; } int x = (int) tb.getPixXFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude()); int y = (int) tb.getPixYFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude()); if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) { radius = small; res.add(n); } } } catch (IndexOutOfBoundsException e) { } } }
Source:
<code>public void testKillEmpty() { Bubble bubble = new Bubble(new Point(0, 0), new Point(0, 0), null); ArrayList<Player> playerList = new ArrayList<Player>(); ArrayList<Unit> unitList = new ArrayList<Unit>(); List<Cell> items = new ArrayList<Cell>(); items.add(Cell.EMPTY); Grid<Cell> cells = new Grid<Cell>(items, 1, 1); Level level = new Level(playerList, unitList, cells); <START> final int TIME_ALMOST_KILL = 498; <END> assertTrue(bubble.isAlive()); for(int i = 0; i < TIME_ALMOST_KILL; i++) { bubble.tick(level); } assertTrue(bubble.isHit()); assertTrue(bubble.isAlive()); bubble.tick(level); assertFalse(bubble.isAlive()); }</code><technical_language>Name 'TIME_ALMOST_KILL' match pattern '^[a-z][a-zA-Z0-9]*$'. [CheckStyle] <naming</technical_language>

Target:
public void testKillEmpty() { Bubble bubble = new Bubble(new Point(0, 0), new Point(0, 0), null); ArrayList<Player> playerList = new ArrayList<Player>(); ArrayList<Unit> unitList = new ArrayList<Unit>(); List<Cell> items = new ArrayList<Cell>(); items.add(Cell.EMPTY); Grid<Cell> cells = new Grid<Cell>(items, 1, 1); Level level = new Level(playerList, unitList, cells); assertTrue(bubble.isAlive()); for (int i = 0; i < TIME_ALMOST_KILL; i++) { bubble.tick(level); } assertTrue(bubble.isHit()); assertTrue(bubble.isAlive()); bubble.tick(level); assertFalse(bubble.isAlive()); }
Source:
<code>public DelegatingResourceDescription getRepresentationDescription(Representation rep) { <START> if (rep instanceof RefRepresentation || rep instanceof DefaultRepresentation) { <END> DelegatingResourceDescription description = new DelegatingResourceDescription(); description.addProperty("uuid"); description.addProperty("value"); description.addProperty("locale"); description.addSelfLink(); description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); return description; } else if (rep instanceof FullRepresentation) { DelegatingResourceDescription description = new DelegatingResourceDescription(); description.addProperty("uuid"); description.addProperty("value"); description.addProperty("locale"); description.addSelfLink(); return description; } return null; }</code><technical_language>ref representation properties: uuid, display, retired (if set true), selflink</technical_language>

Target:
public DelegatingResourceDescription getRepresentationDescription(Representation rep) { if (rep instanceof RefRepresentation) { DelegatingResourceDescription description = new DelegatingResourceDescription(); description.addProperty("uuid"); description.addProperty("display"); description.addSelfLink(); return description; } else if (rep instanceof DefaultRepresentation) { DelegatingResourceDescription description = new DelegatingResourceDescription(); description.addProperty("uuid"); description.addProperty("display"); description.addProperty("value"); description.addProperty("locale"); description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); description.addSelfLink(); return description; } else if (rep instanceof FullRepresentation) { DelegatingResourceDescription description = new DelegatingResourceDescription(); description.addProperty("uuid"); description.addProperty("display"); description.addProperty("value"); description.addProperty("locale"); description.addSelfLink(); return description; } return null; }
Source:
<code>private static String getXMLChunk(String xmlnsAttributeName, String xmlnsXsiAttributeName){ StringBuffer xmlChunk = new StringBuffer(); xmlChunk.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"); xmlChunk.append("<!-- ******Testing tool generated XML****** Version 1.2.\n\n"); xmlChunk.append("Generated On").append(getCXMLDate(true)).append(" for PO ").append(poNumber).append(" Doc# ").append(docNumber).append(" -->\n\n"); xmlChunk.append("<!-- All the cXML attributes are junk values -->\n"); xmlChunk.append("<cXML payloadID=\"200807260401062080.964@eai002\"\n"); xmlChunk.append("timestamp="). append(getCXMLDate(true)).append("\n"); xmlChunk.append("version=\"1.2.014\" xml:lang=\"en\"\n"); if (StringUtils.isNotBlank(xmlnsAttributeName)) { xmlChunk.append(String.format(ATTRIBUTE_NAME_VALUE_FORMAT, xmlnsAttributeName, CuPurapTestConstants.EINVOICE_NAMESPACE_URL)); <START> xmlChunk.append("\n"); <END> } if (StringUtils.isNotBlank(xmlnsXsiAttributeName)) { xmlChunk.append(String.format(ATTRIBUTE_NAME_VALUE_FORMAT, xmlnsXsiAttributeName, CuPurapTestConstants.XSI_NAMESPACE_URL)); } xmlChunk.append(">\n"); xmlChunk.append(getHeaderXMLChunk()); xmlChunk.append(getRequestXMLChunk()); xmlChunk.append("</cXML>"); return xmlChunk.toString(); }</code><technical_language>this is in a constant kfsconstants.newline</technical_language>

Target:
private static String getXMLChunk(String xmlnsAttributeName, String xmlnsXsiAttributeName){ StringBuffer xmlChunk = new StringBuffer(); xmlChunk.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"); xmlChunk.append("<!-- ******Testing tool generated XML****** Version 1.2.\n\n"); xmlChunk.append("Generated On").append(getCXMLDate(true)).append(" for PO ").append(poNumber).append(" Doc# ").append(docNumber).append(" -->\n\n"); xmlChunk.append("<!-- All the cXML attributes are junk values -->\n"); xmlChunk.append("<cXML payloadID=\"200807260401062080.964@eai002\"\n"); xmlChunk.append("timestamp="). append(getCXMLDate(true)).append("\n"); xmlChunk.append("version=\"1.2.014\" xml:lang=\"en\"\n"); if (StringUtils.isNotBlank(xmlnsAttributeName)) { xmlChunk.append(String.format(ATTRIBUTE_NAME_VALUE_FORMAT, xmlnsAttributeName, CuPurapTestConstants.EINVOICE_NAMESPACE_URL)); xmlChunk.append(KFSConstants.NEWLINE); } if (StringUtils.isNotBlank(xmlnsXsiAttributeName)) { xmlChunk.append(String.format(ATTRIBUTE_NAME_VALUE_FORMAT, xmlnsXsiAttributeName, CuPurapTestConstants.XSI_NAMESPACE_URL)); } xmlChunk.append(">\n"); xmlChunk.append(getHeaderXMLChunk()); xmlChunk.append(getRequestXMLChunk()); xmlChunk.append("</cXML>"); return xmlChunk.toString(); }
Source:
<code>private static BinaryResult stackBase64(HttpServletResponse res, final BinaryResult src) throws IOException { BinaryResult b64; long len = src.getContentLength(); if (0 <= len && len <= (7 << 20)) { b64 = base64(src); } else { b64 = new BinaryResult() { @Override public void writeTo(OutputStream out) throws IOException { OutputStream e = BaseEncoding.base64().encodingStream( new OutputStreamWriter(out, ISO_8859_1)); src.writeTo(e); e.flush(); <START> e.close(); <END> } }; } res.setHeader("X-FYI-Content-Encoding", "base64"); res.setHeader("X-FYI-Content-Type", src.getContentType()); return b64.setContentType("text/plain").setCharacterEncoding("ISO-8859-1"); }</code><technical_language>This is interesting. I implementation of StandardBaseEncoding close() is a no-op (or a wrapper for flush()). writes out pending padding. a leak, a false positive, stream writer holds resources besides a buffer GCed. opposed fixing this, some libraries picky padding. said, fix be: try (OutputStreamWriter w = new OutputStreamWriter(out, ISO_8859_1); OutputStream e = BaseEncoding.base64().encodingStream(w)) { src.writeTo(e); e.flush(); }</technical_language>

Target:
private static BinaryResult stackBase64(HttpServletResponse res, final BinaryResult src) throws IOException { BinaryResult b64; long len = src.getContentLength(); if (0 <= len && len <= (7 << 20)) { b64 = base64(src); } else { b64 = new BinaryResult() { @Override public void writeTo(OutputStream out) throws IOException { try (OutputStream e = BaseEncoding.base64().encodingStream( new OutputStreamWriter(out, ISO_8859_1))) { src.writeTo(e); e.flush(); } } }; } res.setHeader("X-FYI-Content-Encoding", "base64"); res.setHeader("X-FYI-Content-Type", src.getContentType()); return b64.setContentType("text/plain").setCharacterEncoding("ISO-8859-1"); }
Source:
<code>private void expandZip() throws CoreException, IOException { IProgressMonitor monitor = getProgessMonitor(); ZipFile zipFile = null; try { zipFile = new ZipFile(zipLocation.toFile()); } catch (IOException e1) { throw e1; } try { Enumeration entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = (ZipEntry) entries.nextElement(); monitor.subTask(entry.getName()); File aFile = computeLocation(entry.getName()).toFile(); File parentFile = null; try { if (entry.isDirectory()) { aFile.mkdirs(); } else { parentFile = aFile.getParentFile(); if (!parentFile.exists()) parentFile.mkdirs(); if (!aFile.exists()) aFile.createNewFile(); copy(zipFile.getInputStream(entry), new FileOutputStream(aFile)); if (entry.getTime() > 0) aFile.setLastModified(entry.getTime()); } } catch (IOException e) { throw e; } monitor.worked(1); } } finally { <START> if (zipFile != null) { <END> zipFile.close(); } } }</code><technical_language>This null check is needed</technical_language>

Target:
private void expandZip() throws CoreException, IOException { IProgressMonitor monitor = getProgessMonitor(); ZipFile zipFile = null; try { zipFile = new ZipFile(zipLocation.toFile()); } catch (IOException e1) { throw e1; } try { Enumeration entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = (ZipEntry) entries.nextElement(); monitor.subTask(entry.getName()); File aFile = computeLocation(entry.getName()).toFile(); File parentFile = null; try { if (entry.isDirectory()) { aFile.mkdirs(); } else { parentFile = aFile.getParentFile(); if (!parentFile.exists()) parentFile.mkdirs(); if (!aFile.exists()) aFile.createNewFile(); copy(zipFile.getInputStream(entry), new FileOutputStream(aFile)); if (entry.getTime() > 0) aFile.setLastModified(entry.getTime()); } } catch (IOException e) { throw e; } monitor.worked(1); } } finally { zipFile.close(); } }
Source:
<code>public void run(String realfile, String host, int port, boolean debug2, List<String> tests) throws MalformedURLException, URISyntaxException { debug = debug2; <START> String file = "reactivesocket-tck-drivers/src/test/resources/client.txt"; <END> if (realfile != null) file = realfile; try { setURI(new URI("tcp://" + host + ":" + port + "/rs")); JavaClientDriver jd = new JavaClientDriver(file, JavaTCPClient::createClient, tests); jd.runTests(); } catch (Exception e) { e.printStackTrace(); } }</code><technical_language>This path wrong <LINK_0></technical_language>

Target:
public void run(String realfile, String host, int port, boolean debug2, List<String> tests) throws MalformedURLException, URISyntaxException { debug = debug2; String file = "reactivesocket-tck-drivers/src/test/resources/client$.txt"; if (realfile != null) file = realfile; try { setURI(new URI("tcp://" + host + ":" + port + "/rs")); JavaClientDriver jd = new JavaClientDriver(file, JavaTCPClient::createClient, tests); jd.runTests(); } catch (Exception e) { e.printStackTrace(); } }
Source:
<code>private char[] versionClientLibs(final char[] chars, int pos, int len, Transformer transformer) { char[] outputChar = chars; String section = StringUtils.trim(new String(chars, pos, len)); <START> Pattern pattern = Pattern.compile(CONDITIONAL_COMMENT_REGEX); <END> Matcher matcher = pattern.matcher(section); if (matcher.matches()) { try { String parsedConditionalMarkup = parseConditionalMarkup(matcher.group(3), transformer); outputChar = StringUtils.replace(new String(chars), matcher.group(3), parsedConditionalMarkup).toCharArray(); } catch (IOException e) { log.error(e.getMessage()); } } return outputChar; }</code><technical_language>pull Pattern.compile(..) out a static var Pattern compilation once? (as Pattern compilation is expensive)</technical_language>

Target:
private char[] versionClientLibs(final char[] chars, int pos, int len, Transformer transformer) { char[] outputChar = chars; final String section = StringUtils.trim(new String(chars, pos, len)); final Matcher matcher = CONDITIONAL_COMMENT_PATTERN.matcher(section); if (matcher.matches()) { try { String parsedConditionalMarkup = parseConditionalMarkup(matcher.group(3), transformer); outputChar = StringUtils.replace(new String(chars), matcher.group(3), parsedConditionalMarkup).toCharArray(); } catch (IOException e) { log.error(e.getMessage()); } } return outputChar; }
Source:
<code>private void closeTableResources() { try { if (Objects.nonNull(statement)) { statement.close(); } if (Objects.nonNull(queryResults)) { queryResults.close(); } liveResultSet = false; } catch (SQLException ex) { <START> } <END> }</code><technical_language>is fine propagate exception here, I prefer log it</technical_language>

Target:
private void closeTableResources() { try { if (Objects.nonNull(statement)) { statement.close(); } if (Objects.nonNull(queryResults)) { queryResults.close(); } liveResultSet = false; } catch (SQLException ex) { logger.log(Level.SEVERE, "Failed to close table resources", ex); } }
Source:
<code>public File getFlywayMigrationDirectory() { String flywayLocation = getFlywayLocations()[0]; <START> File migrationDirectory = new File(System.getProperty("user.home"), Constants.EntitiesMigration.MIGRATION_DIRECTORY); <END> migrationDirectory = new File(migrationDirectory, flywayLocation.substring(flywayLocation.lastIndexOf('/') + 1)); return migrationDirectory; }</code><technical_language>Is this correct, motech.dir here</technical_language>

Target:
public File getFlywayMigrationDirectory() { String flywayLocation = getFlywayLocations()[0]; File migrationDirectory = new File(coreConfigurationService.loadBootstrapConfig().getMotechDir(), Constants.EntitiesMigration.MIGRATION_DIRECTORY); migrationDirectory = new File(migrationDirectory, flywayLocation.substring(flywayLocation.lastIndexOf('/') + 1)); return migrationDirectory; }
Source:
<code>public void init() { employeeRepository.save(new Employee("Bilbo", "Baggins", "thief")); employeeRepository.save(new Employee("Frodo", "Baggins", "ring bearer")); employeeRepository.save(new Employee("Gandalf", "the Wizard", "servant of the Secret Fire")); <START> SecurityContextHolder.getContext().setAuthentication( <END> new UsernamePasswordAuthenticationToken("system", "system", AuthorityUtils.createAuthorityList("ROLE_ADMIN"))); itemRepository.save(new Item("Sting")); itemRepository.save(new Item("the one ring")); SecurityContextHolder.clearContext(); }</code><technical_language>This construct is a times, esp. in test cases? extract int a SecurityUtils.runAs(String username, String password, String... roles)</technical_language>

Target:
public void init() { employeeRepository.save(new Employee("Bilbo", "Baggins", "thief")); employeeRepository.save(new Employee("Frodo", "Baggins", "ring bearer")); employeeRepository.save(new Employee("Gandalf", "the Wizard", "servant of the Secret Fire")); SecurityUtils.runAs("system", "system", "ROLE_ADMIN"); itemRepository.save(new Item("Sting")); itemRepository.save(new Item("the one ring")); SecurityContextHolder.clearContext(); }
Source:
<code>private boolean isWithoutRoot(Parameter[] parameters, JsonObject root, ControllerMethod method) { <START> if(method.containsAnnotation(Consumes.class) && method.getMethod().getAnnotation(Consumes.class).withoutRoot()) { <END> return true; } for (Parameter parameter : parameters) { if (root.get(parameter.getName()) != null) return false; } return true; }</code><technical_language>I 1st check is needed, if method contains Consumes, observer called</technical_language>

Target:
private boolean isWithoutRoot(Parameter[] parameters, JsonObject root, ControllerMethod method) { if(method.getMethod().getAnnotation(Consumes.class).withoutRoot()) { return true; } for (Parameter parameter : parameters) { if (root.get(parameter.getName()) != null) return false; } return true; }
Source:
<code><START> protected Properties initJobProperties(Element root) { <END> Properties properties = new Properties(); Node propertiesNode = root.getElementsByTagName(JOB_PROPERTIES_ELEMENT_NAME).item(0); if(propertiesNode != null) { NodeList children = propertiesNode.getChildNodes(); for(int i=0; i < children.getLength(); i++) { Node child = children.item(i); if(JOB_PROPERTY_ELEMENT_NAME.equals(child.getLocalName())) { NamedNodeMap attributes = child.getAttributes(); Node name = attributes.getNamedItem(JOB_PROPERTY_ELEMENT_NAME_ATTRIBUTE); Node value = attributes.getNamedItem(JOB_PROPERTY_ELEMENT_VALUE_ATTRIBUTE); properties.setProperty(name.getNodeValue(), value.getNodeValue()); } } } return properties; }</code><technical_language>Is this want people able override</technical_language>

Target:
private Properties initJobProperties(Element root) { Properties properties = new Properties(); Node propertiesNode = root.getElementsByTagName(JOB_PROPERTIES_ELEMENT_NAME).item(0); if(propertiesNode != null) { NodeList children = propertiesNode.getChildNodes(); for(int i=0; i < children.getLength(); i++) { Node child = children.item(i); if(JOB_PROPERTY_ELEMENT_NAME.equals(child.getLocalName())) { NamedNodeMap attributes = child.getAttributes(); Node name = attributes.getNamedItem(JOB_PROPERTY_ELEMENT_NAME_ATTRIBUTE); Node value = attributes.getNamedItem(JOB_PROPERTY_ELEMENT_VALUE_ATTRIBUTE); properties.setProperty(name.getNodeValue(), value.getNodeValue()); } } } return properties; }
Source:
<code>private void checkForMissedServletContexts() { Optional<BundleContext> optionalBundleContext = getContext(); if (!optionalBundleContext.isPresent()) { LOGGER.error( "Problem retrieving the bundle `Platform :: Error :: Page Injector` after it's just been initialized"); return; } final BundleContext context = optionalBundleContext.get(); ServiceReference<ServletContext>[] references = null; try { references = (ServiceReference<ServletContext>[]) context.getAllServiceReferences( null, "(" + Constants.OBJECTCLASS + "=javax.servlet.ServletContext)"); } catch (InvalidSyntaxException e) { LOGGER.error( "Problem getting ServletContexts from OSGI, One of the servlets running might print stack traces to the browser. A system restart is recommended. See debug logs for additional details."); <START> LOGGER.debug("Additional Details:", e); <END> } if (references == null) return; for (ServiceReference<ServletContext> reference : references) { final Bundle refBundle = reference.getBundle(); final BundleContext bundlectx = refBundle.getBundleContext(); ServletContext service = bundlectx.getService(reference); Optional<ServletContextHandler> optionalHttpContext = getHTTPContext(service, refBundle); if (!optionalHttpContext.isPresent()) return; ServletContextHandler httpContext = optionalHttpContext.get(); ErrorPageErrorHandler errorPageErrorHandler = (ErrorPageErrorHandler) httpContext.getErrorHandler(); final Map<String, String> errorPages = errorPageErrorHandler.getErrorPages(); if (errorPages.isEmpty()) { createAndAddErrorPageHandler(httpContext, refBundle); } } }</code><technical_language>rely messages back-to-back in log file for context. In a busy system, other threads easily interject log messages them. a more descriptive message for debug log</technical_language>

Target:
private void checkForMissedServletContexts() { Optional<BundleContext> optionalBundleContext = getContext(); if (!optionalBundleContext.isPresent()) { LOGGER.warn( "Problem retrieving the bundle `Platform :: Error :: Page Injector` after it's just been initialized"); return; } final BundleContext context = optionalBundleContext.get(); getServiceReferences(context) .ifPresent(e -> Arrays.asList(e).forEach(this::addMissedErrorPage)); }
Source:
<code>protected boolean setAndValidateDiskProfiles() { if (getParameters().getVmTemplate().getDiskList() != null) { Map<DiskImage, Guid> map = new HashMap<>(); for (DiskImage diskImage : getParameters().getVmTemplate().getDiskList()) { <START> if (diskImage.getDiskStorageType() == DiskStorageType.IMAGE) { <END> map.put(diskImage, imageToDestinationDomainMap.get(diskImage.getId())); } } return validate(DiskProfileHelper.setAndValidateDiskProfiles(map)); } return true; }</code><technical_language>need for if..diskimage is diskimage :)</technical_language>

Target:
protected boolean setAndValidateDiskProfiles() { if (getParameters().getVmTemplate().getDiskList() != null) { Map<DiskImage, Guid> map = new HashMap<>(); for (DiskImage diskImage : getParameters().getVmTemplate().getDiskList()) { map.put(diskImage, imageToDestinationDomainMap.get(diskImage.getId())); } return validate(DiskProfileHelper.setAndValidateDiskProfiles(map)); } return true; }
Source:
<code>public void testCherryPickConflictResolution() throws Exception { Git git = new Git(db); RevCommit sideCommit = prepareCherryPick(git); CherryPickResult result = git.cherryPick().include(sideCommit.getId()) .call(); assertEquals(CherryPickStatus.CONFLICTING, result.getStatus()); assertTrue(new File(db.getDirectory(), Constants.MERGE_MSG).exists()); <START> assertEquals("side\n\nConflicts:\n\ta", db.readMergeCommitMsg()); <END> assertTrue(new File(db.getDirectory(), Constants.CHERRY_PICK_HEAD) .exists()); assertEquals(sideCommit.getId(), db.readCherryPickHead()); assertEquals(RepositoryState.CHERRY_PICKING, db.getRepositoryState()); writeTrashFile("a", "a"); git.add().addFilepattern("a").call(); assertEquals(RepositoryState.CHERRY_PICKING_RESOLVED, db.getRepositoryState()); git.commit().setOnly("a").setMessage("resolve").call(); assertEquals(RepositoryState.SAFE, db.getRepositoryState()); }</code><technical_language>Message end in \n</technical_language>

Target:
public void testCherryPickConflictResolution() throws Exception { Git git = new Git(db); RevCommit sideCommit = prepareCherryPick(git); CherryPickResult result = git.cherryPick().include(sideCommit.getId()) .call(); assertEquals(CherryPickStatus.CONFLICTING, result.getStatus()); assertTrue(new File(db.getDirectory(), Constants.MERGE_MSG).exists()); assertEquals("side\n\nConflicts:\n\ta\n", db.readMergeCommitMsg()); assertTrue(new File(db.getDirectory(), Constants.CHERRY_PICK_HEAD) .exists()); assertEquals(sideCommit.getId(), db.readCherryPickHead()); assertEquals(RepositoryState.CHERRY_PICKING, db.getRepositoryState()); writeTrashFile("a", "a"); git.add().addFilepattern("a").call(); assertEquals(RepositoryState.CHERRY_PICKING_RESOLVED, db.getRepositoryState()); git.commit().setOnly("a").setMessage("resolve").call(); assertEquals(RepositoryState.SAFE, db.getRepositoryState()); }
Source:
<code>private void promptForFactorString( String title, final Operation complete, final String columnName, final String columnType) { globalDisplay_.promptForText( title, <START> "Please a comma separated list of factors", <END> "", new OperationWithInput<String>() { @Override public void execute(final String formatString) { String[] parts = formatString.split(","); String factorsString = ""; boolean first = true; for (String part : parts) { part = part.replaceAll("^\\s+|\\s+$", ""); if (!first) factorsString = factorsString + ", "; factorsString = factorsString + "\"" + part + "\""; first = false; } importOptions_.setColumnDefinition(columnName, columnType, "c(" + factorsString + ")"); complete.execute(); } }); }</code><technical_language>Missing "insert" similar? I if piggyback Shiny selectize.js here. (probably late in game for this release worth thinking about)</technical_language>

Target:
private void promptForFactorString( String title, final Operation complete, final String columnName, final String columnType) { globalDisplay_.promptForText( title, "Please insert a comma separated list of factors", "", new OperationWithInput<String>() { @Override public void execute(final String formatString) { String[] parts = formatString.split(","); String factorsString = ""; boolean first = true; for (String part : parts) { part = part.replaceAll("^\\s+|\\s+$", ""); if (!first) factorsString = factorsString + ", "; factorsString = factorsString + "\"" + part + "\""; first = false; } importOptions_.setColumnDefinition(columnName, columnType, "c(" + factorsString + ")"); complete.execute(); } }); }
Source:
<code>protected void ExecuteVmCommand() { AddCustomValue("InterfaceType", (VmInterfaceType.forValue(getParameters().getInterface().getType()).getInterfaceTranslation()).toString()); this.setVmName(DbFacade.getInstance().getVmStaticDAO().get(getParameters().getVmId()).getvm_name()); if (StringHelper.isNullOrEmpty(getParameters().getInterface().getMacAddress())) { String mac = null; RefObject<String> tempRefObject = new RefObject<String>(mac); MacPoolManager.getInstance().allocateNewMac(tempRefObject); mac = tempRefObject.argvalue; getParameters().getInterface().setMacAddress(mac); } getParameters().getInterface().setSpeed( VmInterfaceType.forValue( getParameters().getInterface().getType()).getSpeed()); getParameters().getInterface().setId(Guid.NewGuid()); getParameters().getInterface().setVmId(getParameters().getVmId()); DbFacade dbFacade = DbFacade.getInstance(); dbFacade .getVmNetworkInterfaceDAO() .save(getParameters().getInterface()); dbFacade .getVmNetworkStatisticsDAO() .save(getParameters().getInterface().getStatistics()); VmDevice vmDevice = VmDeviceUtils.addManagedDevice(new VmDeviceId(getParameters().getInterface().getId(), getParameters().getVmId()), VmDeviceType.INTERFACE, VmDeviceType.BRIDGE, "", true, false); <START> <END> boolean succeded = true; VmDynamic vmDynamic = DbFacade.getInstance().getVmDynamicDAO().get(getParameters().getVmId()); if (vmDynamic.getstatus() == VMStatus.Up) { succeded = hotPlugNic(vmDevice, vmDynamic); if (!succeded) { getReturnValue().getExecuteFailedMessages().add("Failed hot-plugging nic to VM"); } } setSucceeded(succeded); }</code><technical_language>whitespace</technical_language>

Target:
protected void ExecuteVmCommand() { AddCustomValue("InterfaceType", (VmInterfaceType.forValue(getParameters().getInterface().getType()).getInterfaceTranslation()).toString()); this.setVmName(DbFacade.getInstance().getVmStaticDAO().get(getParameters().getVmId()).getvm_name()); if (StringHelper.isNullOrEmpty(getParameters().getInterface().getMacAddress())) { String mac = null; RefObject<String> tempRefObject = new RefObject<String>(mac); MacPoolManager.getInstance().allocateNewMac(tempRefObject); mac = tempRefObject.argvalue; getParameters().getInterface().setMacAddress(mac); } getParameters().getInterface().setSpeed( VmInterfaceType.forValue( getParameters().getInterface().getType()).getSpeed()); getParameters().getInterface().setId(Guid.NewGuid()); getParameters().getInterface().setVmId(getParameters().getVmId()); DbFacade dbFacade = DbFacade.getInstance(); dbFacade .getVmNetworkInterfaceDAO() .save(getParameters().getInterface()); dbFacade .getVmNetworkStatisticsDAO() .save(getParameters().getInterface().getStatistics()); VmDevice vmDevice = VmDeviceUtils.addManagedDevice(new VmDeviceId(getParameters().getInterface().getId(), getParameters().getVmId()), VmDeviceType.INTERFACE, VmDeviceType.BRIDGE, "", true, false); boolean succeded = true; VmDynamic vmDynamic = getVm().getDynamicData(); if (vmDynamic.getstatus() == VMStatus.Up) { succeded = hotPlugNic(vmDevice, vmDynamic); if (!succeded) { getReturnValue().getExecuteFailedMessages().add("Failed hot-plugging nic to VM"); } } setSucceeded(succeded); }