auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void init(final int size) { this.viewpointsFromPlugin = new HashSet<Viewpoint>(size); this.viewpointsFromWorkspace = new HashSet<Viewpoint>(size); this.resourceSet = new ResourceSetImpl(); crossReferencer = new ECrossReferenceAdapter(); this.resourceSet.eAdapters().add(crossReferencer); try { <START> final IWorkspace workspace = ResourcesPlugin.getWorkspace(); <END> workspace.addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); } catch (IllegalStateException e) { } initViewpointsFromPlugins(); refreshComponentsFromWorkspace(); }</code><technical_language>mimic EcorePlugin.getWorkspaceRoot() in a dedicated class instead of relying exception making update calless code base. checks for ResourcesBundle and/or a specific property "org.eclipse.emf.ecore.plugin.EcorePlugin.doNotLoadResourcesPlugin"</technical_language>

Target:
public void init(final int size) { this.viewpointsFromPlugin = new HashSet<Viewpoint>(size); this.viewpointsFromWorkspace = new HashSet<Viewpoint>(size); this.resourceSet = new ResourceSetImpl(); crossReferencer = new ECrossReferenceAdapter(); this.resourceSet.eAdapters().add(crossReferencer); IWorkspaceRoot workspaceRoot = EcorePlugin.getWorkspaceRoot(); if (workspaceRoot != null) { workspaceRoot.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); } initViewpointsFromPlugins(); refreshComponentsFromWorkspace(); }
Source:
<code>public SolObject toObj(SolGame game) { <START> Vector2 position = adjustDesiredPosition(game, myPos, mySz); <END> return game.getAsteroidBuilder().build(game, position, myTex, mySz, myAngle, myRotSpd, mySpd, myRemoveController); }</code><technical_language>this line, myPos actual position of asteroid (position) out of sync. modify of myPos, create a new Vector2. Luckily for you, done (by mistake)</technical_language>

Target:
public SolObject toObj(SolGame game) { adjustDesiredPosition(game); return game.getAsteroidBuilder().build(game, position, tex, size, angle, rotateSpeed, speed, removeController); }
Source:
<code><START> public void setUp() throws Exception <END> { aGraph = new ClassDiagramGraph(); aRootNodes = (ArrayList<Node>) aGraph.getRootNodes(); aNode = new ClassNode(); aGraph.addNode(aNode, new Point2D.Double()); aNeedsLayout = aGraph.getClass().getSuperclass().getDeclaredField("aNeedsLayout"); aNeedsLayout.setAccessible(true); aNodesToBeRemoved = aGraph.getClass().getSuperclass().getDeclaredField("aNodesToBeRemoved"); aNodesToBeRemoved.setAccessible(true); aDeleteNodeCommand = new DeleteNodeCommand(aGraph, aNode); }</code><technical_language>catch relevant exception types in a catch clause calls fail(), cleaner</technical_language>

Target:
public void setUp() throws Exception { aGraph = new ClassDiagramGraph(); aNode = new ClassNode(); aNodesToBeRemoved = aGraph.getClass().getSuperclass().getDeclaredField("aNodesToBeRemoved"); aNodesToBeRemoved.setAccessible(true); aDeleteNodeCommand = new DeleteNodeCommand(aGraph, aNode); }
Source:
<code>protected boolean set(Entity dataHolder, Set<String> value) { <START> for(String oldTag : dataHolder.getTags()) <END> { dataHolder.removeTag(oldTag); } for(String newTag : value) { if(!dataHolder.addTag(newTag)) { return false; } } return true; }</code><technical_language>for (</technical_language>

Target:
protected boolean set(Entity dataHolder, Set<String> value) { for (String oldTag : dataHolder.getTags()) { dataHolder.removeTag(oldTag); } List<String> added = Lists.newArrayList(); for (String newTag : value) { if (!dataHolder.addTag(newTag)) { for (String tag : added) { dataHolder.removeTag(tag); } return false; } added.add(newTag); } return true; }
Source:
<code>public void testGetDRTableNamePartitionColumnMapping() throws Exception { String schema = "CREATE TABLE A (C1 INTEGER NOT NULL, C2 TIMESTAMP NOT NULL); PARTITION TABLE A ON COLUMN C1;\n" + "CREATE TABLE B (C1 BIGINT NOT NULL, C2 SMALLINT NOT NULL); PARTITION TABLE B ON COLUMN C1;\n" + "CREATE TABLE C (C1 TINYINT NOT NULL, C2 VARCHAR(3) NOT NULL); PARTITION TABLE C ON COLUMN C1;\n" + <START> "DR TABLE B;\n"; <END> String testDir = BuildDirectoryUtils.getBuildDirectoryPath(); final File file = VoltFile.createTempFile("DRTableNamePartitionColumnMapping", ".jar", new File(testDir)); VoltProjectBuilder builder = new VoltProjectBuilder(); builder.addLiteralSchema(schema); builder.compile(file.getPath()); Catalog cat = TestCatalogDiffs.catalogForJar(file.getPath()); file.delete(); Map<String, Integer> mapping = CatalogUtil.getDRTableNamePartitionColumnMapping(cat.getClusters().get("cluster").getDatabases().get("database")); assertEquals(1, mapping.size()); assertEquals(true, mapping.containsKey("B")); assertEquals(0, mapping.get("B").intValue()); }</code><technical_language>Add a case for replicated table</technical_language>

Target:
public void testGetDRTableNamePartitionColumnMapping() throws Exception { String schema = "CREATE TABLE A (C1 INTEGER NOT NULL, C2 TIMESTAMP NOT NULL); PARTITION TABLE A ON COLUMN C1;\n" + "CREATE TABLE B (C1 BIGINT NOT NULL, C2 SMALLINT NOT NULL); PARTITION TABLE B ON COLUMN C1;\n" + "CREATE TABLE C (C1 TINYINT NOT NULL, C2 VARCHAR(3) NOT NULL);\n" + "DR TABLE B; DR TABLE C;\n"; String testDir = BuildDirectoryUtils.getBuildDirectoryPath(); final File file = VoltFile.createTempFile("DRTableNamePartitionColumnMapping", ".jar", new File(testDir)); VoltProjectBuilder builder = new VoltProjectBuilder(); builder.addLiteralSchema(schema); builder.compile(file.getPath()); Catalog cat = TestCatalogDiffs.catalogForJar(file.getPath()); file.delete(); Map<String, Integer> mapping = CatalogUtil.getDRTableNamePartitionColumnMapping(cat.getClusters().get("cluster").getDatabases().get("database")); assertEquals(1, mapping.size()); assertEquals(true, mapping.containsKey("B")); assertEquals(0, mapping.get("B").intValue()); }
Source:
<code>public Object adapt( Class<E> clazz, IAdaptingType entity, IResponder nextResponder ) { BackendlessCollection<?> result = null; try { BackendlessCollection<E> list = createListOfType( clazz, entity ); AnonymousObject bodyValue = (AnonymousObject) ((NamedObject) entity).getTypedObject(); ArrayType data = (ArrayType) bodyValue.getProperties().get( "data" ); if( data != null ) { Object[] dataArray = (Object[]) data.getArray(); for( int i = 0; i < dataArray.length; i++ ) { <START> if( ((NamedObject) dataArray[ i ]).getObjectName().contains( GeoCluster.class.getSimpleName() ) ) <END> { ((NamedObject) dataArray[ i ]).setDefaultType( GeoCluster.class ); } else { ((NamedObject) dataArray[ i ]).setDefaultType( clazz ); } } } result = (BackendlessCollection<?>) entity.adapt( list.getClass() ); if( nextResponder != null ) nextResponder.responseHandler( result ); } catch( AdaptingException e ) { Fault fault = new Fault( "Unable to adapt response to BackendlessCollection", e.getMessage() ); if( nextResponder != null ) nextResponder.errorHandler( fault ); } return result; }</code><technical_language>is a special logic for GeoCluster? I handled general case</technical_language>

Target:
public Object adapt( Class<E> clazz, IAdaptingType entity, IResponder nextResponder ) { BackendlessCollection<?> result = null; try { BackendlessCollection<E> list = createListOfType( clazz ); AnonymousObject bodyValue = (AnonymousObject) ((NamedObject) entity).getTypedObject(); ArrayType data = (ArrayType) bodyValue.getProperties().get( "data" ); if( data != null ) { Object[] dataArray = (Object[]) data.getArray(); for( int i = 0; i < dataArray.length; i++ ) { try { String expectedClassName = clazz.getCanonicalName(); String comingClassName = ((NamedObject) dataArray[ i ]).getObjectName(); ( (NamedObject) dataArray[ i ] ).setDefaultType( Class.forName( expectedClassName.substring( 0, expectedClassName.lastIndexOf( '.' ) ) + comingClassName.substring( comingClassName.lastIndexOf( '.' ) ) ) ); } catch( ClassNotFoundException e ) { ((NamedObject) dataArray[ i ]).setDefaultType( clazz ); } } } result = (BackendlessCollection<?>) entity.adapt( list.getClass() ); if( nextResponder != null ) nextResponder.responseHandler( result ); } catch( AdaptingException e ) { Fault fault = new Fault( "Unable to adapt response to BackendlessCollection", e.getMessage() ); if( nextResponder != null ) nextResponder.errorHandler( fault ); } return result; }
Source:
<code>private GetResponseBodyResponse readResponseBody(String requestId) throws IOException, JsonRpcException { GetResponseBodyResponse response = new GetResponseBodyResponse(); ResponseBodyData bodyData; try { bodyData = mResponseBodyFileManager.readFile(requestId); } catch (OutOfMemoryError e) { <START> throw new JsonRpcException(new JsonRpcError(JsonRpcError.ErrorCode.PARSER_ERROR, <END> e.toString(), null )); } response.body = bodyData.data; response.base64Encoded = bodyData.base64Encoded; return response; }</code><technical_language>ErrorCode.INTERNAL_ERROR</technical_language>

Target:
private GetResponseBodyResponse readResponseBody(String requestId) throws IOException, JsonRpcException { GetResponseBodyResponse response = new GetResponseBodyResponse(); ResponseBodyData bodyData; try { bodyData = mResponseBodyFileManager.readFile(requestId); } catch (OutOfMemoryError e) { throw new JsonRpcException(new JsonRpcError(JsonRpcError.ErrorCode.INTERNAL_ERROR, e.toString(), null )); } response.body = bodyData.data; response.base64Encoded = bodyData.base64Encoded; return response; }
Source:
<code>public MaskValidatorTest(String mask, boolean isNetmaskValidFormat, boolean isMaskValid, boolean isPrefixValid) { this.mask = mask; this.isNetmaskValidFormat = isNetmaskValidFormat; <START> this.isMaskValid = isMaskValid; <END> this.isPrefixValid = isPrefixValid; }</code><technical_language>members similarly named, e.g. isNetmaskValidFormat isNetmaskValidValue</technical_language>

Target:
public MaskValidatorTest(String mask, boolean isNetmaskValidFormat, boolean isMaskValid, boolean isPrefixValid) { this.mask = mask; this.isNetmaskValidFormat = isNetmaskValidFormat; this.isNetmaskValidValue = isMaskValid; this.isPrefixValid = isPrefixValid; }
Source:
<code>protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); parent.getShell().setText(UIText.CommitDialog_CommitChanges); container = toolkit.createComposite(container); GridDataFactory.fillDefaults().grab(true, true).applyTo(container); toolkit.paintBordersFor(container); GridLayoutFactory.swtDefaults().applyTo(container); final SashForm sashForm= new SashForm(container, SWT.VERTICAL | SWT.FILL); toolkit.adapt(sashForm, true, true); sashForm.setLayoutData(GridDataFactory.fillDefaults().grab(true, true) .create()); createMessageAndPersonArea(sashForm); filesSection = createFileSection(sashForm); sashForm.setWeights(new int[] { 50, 50 }); applyDialogFont(container); container.pack(); commitText.setFocus(); Image titleImage = UIIcons.WIZBAN_CONNECT_REPO.createImage(); UIUtils.hookDisposal(parent, titleImage); setTitleImage(titleImage); setTitle(UIText.CommitDialog_Title); <START> setMessage(UIText.CommitDialog_Message, <END> IMessageProvider.INFORMATION); filesViewer.addCheckStateListener(new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent event) { updateMessage(); } }); updateFileSectionText(); return container; }</code><technical_language>put "if(ignoreErrors != null)" decide if show a normal information setMessage(UIText.CommitDialog_MessageErrors, IMessageProvider.WARNING);</technical_language>

Target:
protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); parent.getShell().setText(UIText.CommitDialog_CommitChanges); container = toolkit.createComposite(container); GridDataFactory.fillDefaults().grab(true, true).applyTo(container); toolkit.paintBordersFor(container); GridLayoutFactory.swtDefaults().applyTo(container); final SashForm sashForm= new SashForm(container, SWT.VERTICAL | SWT.FILL); toolkit.adapt(sashForm, true, true); sashForm.setLayoutData(GridDataFactory.fillDefaults().grab(true, true) .create()); createMessageAndPersonArea(sashForm); filesSection = createFileSection(sashForm); sashForm.setWeights(new int[] { 50, 50 }); applyDialogFont(container); container.pack(); commitText.setFocus(); Image titleImage = UIIcons.WIZBAN_CONNECT_REPO.createImage(); UIUtils.hookDisposal(parent, titleImage); setTitleImage(titleImage); setTitle(UIText.CommitDialog_Title); if (ignoreErrors != null) { setMessage(UIText.CommitDialog_MessageErrors, IMessageProvider.WARNING); } else { setMessage(UIText.CommitDialog_Message, IMessageProvider.INFORMATION); } filesViewer.addCheckStateListener(new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent event) { updateMessage(); } }); updateFileSectionText(); return container; }
Source:
<code>public WorkloadClock getClock() { if (taskConfig.users != null) { return new UserClock(taskConfig, tickInterval, shutdown); } else{ if (taskConfig.tps != null){ TpsClockConfiguration tpsClockConfiguration = new TpsClockConfiguration(); tpsClockConfiguration.setTickInterval(tickInterval); tpsClockConfiguration.setTps(taskConfig.tps.value); return tpsClockConfiguration.getClock(); }else { if (taskConfig.virtualUser != null){ VirtualUsersClockConfiguration conf = new VirtualUsersClockConfiguration(); conf.setTickInterval(taskConfig.virtualUser.tickInterval); conf.setUsers(taskConfig.virtualUser.count); return conf.getClock(); <START> }else{ <END> return new ExactInvocationsClock(taskConfig.invocation.exactcount, taskConfig.invocation.threads, taskConfig.delay); } } } }</code><technical_language>if taskConfig.invocation is null add check, please</technical_language>

Target:
public WorkloadClock getClock() { if (taskConfig.users != null) { return new UserClock(taskConfig, tickInterval, shutdown); }else if (taskConfig.tps != null){ TpsClockConfiguration tpsClockConfiguration = new TpsClockConfiguration(); tpsClockConfiguration.setTickInterval(tickInterval); tpsClockConfiguration.setTps(taskConfig.tps.value); return tpsClockConfiguration.getClock(); }else if (taskConfig.virtualUser != null){ VirtualUsersClockConfiguration conf = new VirtualUsersClockConfiguration(); conf.setTickInterval(taskConfig.virtualUser.tickInterval); conf.setUsers(taskConfig.virtualUser.count); return conf.getClock(); }else if (taskConfig.invocation != null){ return new ExactInvocationsClock(taskConfig.invocation.exactcount, taskConfig.invocation.threads, taskConfig.delay); }else return null; }
Source:
<code>public void shouldNotRewriteExistingLibraryIfThereAreNoChanges() throws Exception{ SQLiteLibraryLoader.load(); File extractedPath = SQLiteLibraryLoader.getNativeLibraryPath(); assertThat(extractedPath).exists(); long time = extractedPath.lastModified(); <START> Thread.sleep(2); <END> SQLiteLibraryLoader.mustReload(); SQLiteLibraryLoader.load(); extractedPath = SQLiteLibraryLoader.getNativeLibraryPath(); assertThat(extractedPath.lastModified()).isEqualTo(time); }</code><technical_language>sleep in tests, is this needed</technical_language>

Target:
public void shouldNotRewriteExistingLibraryIfThereAreNoChanges() throws Exception{ loader.doLoad(); File extractedPath = loader.getNativeLibraryPath(); assertThat(extractedPath).exists(); final long resetTime = 1234L; assertThat(extractedPath.setLastModified(resetTime)).describedAs("Cannot reset modification date").isTrue(); long time = extractedPath.lastModified(); assertThat(time).isLessThanOrEqualTo(resetTime); loader.mustReload(); loader.doLoad(); extractedPath = loader.getNativeLibraryPath(); assertThat(extractedPath.lastModified()).isEqualTo(time); }
Source:
<code>private boolean isInForeground() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { ActivityManager.RunningAppProcessInfo info = new ActivityManager.RunningAppProcessInfo(); ActivityManager.getMyMemoryState(info); return info.importance <= ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE; } else { <START> return true; <END> } }</code><technical_language>get pre jelly bean too: internal fun retrieveProcessInfo(): RunningAppProcessInfo? { val activityManager = application.getSystemService( Context.ACTIVITY_SERVICE ) ActivityManager val runningProcesses: List<RunningAppProcessInfo>? try { runningProcesses = activityManager.runningAppProcesses } catch (exception: SecurityException) { // SecurityException: Isolated process allowed call getRunningAppProcesses return null } if (runningProcesses != null) { val myPid = android.os.Process.myPid() for (process in runningProcesses) { if (process.pid == myPid) { return process } } } return null }</technical_language>

Target:
private boolean isInForeground() { ActivityManager.RunningAppProcessInfo info = getProcessInfo(); if (info != null) { return info.importance <= ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE; } else { return true; } }
Source:
<code>private double calculateGcNormCoverage(final double meanReadsPerWindow, final int[] readsByGc, final int start, final int end) { int windowsTotal = 0; double sum = 0.0; for (int i = start; i <= end; i++) { if (windowsByGc[i] != 0) { final double norm = ((double) readsByGc[i] / windowsByGc[i]) / meanReadsPerWindow; sum = sum + (norm*windowsByGc[i]); windowsTotal = windowsTotal + windowsByGc[i]; } } <START> if(windowsTotal == 0) { return 0.0; } <END> else { return (sum / (double) windowsTotal); } }</code><technical_language>needs a space b/w if (. braces needs newlines</technical_language>

Target:
private double calculateGcNormCoverage(final double meanReadsPerWindow, final int[] readsByGc, final int start, final int end) { int windowsTotal = 0; double sum = 0.0; for (int i = start; i <= end; i++) { if (windowsByGc[i] != 0) { sum += (double) readsByGc[i]; windowsTotal += windowsByGc[i]; } } if (windowsTotal == 0) { return 0.0; } else { return (sum / (windowsTotal*meanReadsPerWindow)); } }
Source:
<code>private String chooseImageSource(String thumbUrl, Uri localUri) { <START> String imageSource = thumbUrl; <END> if (TextUtils.isEmpty(imageSource)) { imageSource = localUri != null ? localUri.toString() : null; } return imageSource; }</code><technical_language>do this, return is correct, need a variable this collapse a ternary if choose</technical_language>

Target:
private String chooseImageSource(String thumbUrl, Uri localUri) { return !TextUtils.isEmpty(thumbUrl) ? thumbUrl : localUri != null ? localUri.toString() : null; }
Source:
<code>public static void main(String[] args) { try { new StartMain(args).go(); System.exit(0); } catch (Throwable t) { <START> StreamSupport.stream(exceptionHandlerLoader.spliterator(), false) <END> .filter(eh -> eh.supports(t)) .findFirst() .orElse(new DefaultExceptionHandler()) .handle(t); System.exit(1); } }</code><technical_language>I is need streams here..</technical_language>

Target:
public static void main(String[] args) { try { new StartMain(args).go(); } catch (Throwable t) { StreamSupport.stream(exceptionHandlerLoader.spliterator(), false) .filter(eh -> eh.supports(t)) .findFirst() .orElse(new DefaultExceptionHandler()) .handle(t); System.exit(1); } }
Source:
<code>public void testTopologyWorkerCpu() throws Exception { double result = MesosCommon.topologyWorkerCpu(conf, info); double expectedResult = MesosCommon.DEFAULT_WORKER_CPU; assertEquals(result, expectedResult, 0.001); double cpuConfig = MesosCommon.MESOS_MIN_CPU; cpuConfig -= 0.001; conf.put(MesosCommon.WORKER_CPU_CONF, cpuConfig); result = MesosCommon.topologyWorkerCpu(conf, info); expectedResult = MesosCommon.DEFAULT_WORKER_CPU; <START> assertEquals(result, expectedResult, 0.0001); <END> conf.put(MesosCommon.WORKER_CPU_CONF, 1.5); info = new TopologyDetails("t2", conf, new StormTopology(), 2); result = MesosCommon.topologyWorkerCpu(conf, info); expectedResult = 1.5; assertEquals(result, expectedResult, 0.001); conf = new HashMap<>(); conf.put(MesosCommon.WORKER_CPU_CONF, "2"); info = new TopologyDetails("t3", conf, new StormTopology(), 1); result = MesosCommon.topologyWorkerCpu(conf, info); expectedResult = 1; assertEquals(result, expectedResult, 0.001); Map nimbusConf = new HashMap<>(); nimbusConf.put(MesosCommon.WORKER_CPU_CONF, 2); conf = new HashMap<>(); conf.put(MesosCommon.WORKER_CPU_CONF, 1.5); info = new TopologyDetails("t4", conf, new StormTopology(), 1); result = MesosCommon.topologyWorkerCpu(nimbusConf, info); expectedResult = 1.5; assertEquals(result, expectedResult, 0.001); }</code><technical_language>Define private static final DELTA = 0.0001 a member in rest of code</technical_language>

Target:
public void testTopologyWorkerCpu() throws Exception { double result = MesosCommon.topologyWorkerCpu(conf, info); double expectedResult = MesosCommon.DEFAULT_WORKER_CPU; assertEquals(result, expectedResult, DELTA); double cpuConfig = MesosCommon.MESOS_MIN_CPU; cpuConfig -= 0.001; conf.put(MesosCommon.WORKER_CPU_CONF, cpuConfig); result = MesosCommon.topologyWorkerCpu(conf, info); expectedResult = MesosCommon.DEFAULT_WORKER_CPU; assertEquals(result, expectedResult, DELTA); conf.put(MesosCommon.WORKER_CPU_CONF, null); result = MesosCommon.topologyWorkerCpu(conf, info); expectedResult = MesosCommon.DEFAULT_WORKER_CPU; assertEquals(result, expectedResult, DELTA); conf.put(MesosCommon.WORKER_CPU_CONF, 1.5); info = new TopologyDetails("t2", conf, new StormTopology(), 2); result = MesosCommon.topologyWorkerCpu(conf, info); expectedResult = 1.5; assertEquals(result, expectedResult, DELTA); conf = new HashMap<>(); conf.put(MesosCommon.WORKER_CPU_CONF, "2"); info = new TopologyDetails("t3", conf, new StormTopology(), 1); result = MesosCommon.topologyWorkerCpu(conf, info); expectedResult = 1; assertEquals(result, expectedResult, DELTA); Map nimbusConf = new HashMap<>(); nimbusConf.put(MesosCommon.WORKER_CPU_CONF, 2); conf = new HashMap<>(); conf.put(MesosCommon.WORKER_CPU_CONF, 1.5); info = new TopologyDetails("t4", conf, new StormTopology(), 1); result = MesosCommon.topologyWorkerCpu(nimbusConf, info); expectedResult = 1.5; assertEquals(result, expectedResult, DELTA); }
Source:
<code><START> public Version nextVersion() { <END> Version result = event.context() .getVersion(); return result; }</code><technical_language>Please check if this method public in a private static final class. parent method is protected</technical_language>

Target:
protected Version nextVersion() { Version result = event.context() .getVersion(); return result; }
Source:
<code>public boolean validate(Source xml, Source xsd) throws SAXException { SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory.newSchema(xsd); Validator validator = schema.newValidator(); String language = UserContext.getCurrentUser().getLang(); Locale locale = Strings.areEqual(language, "en") ? Locale.ROOT : new Locale(language); validator.setProperty("<LINK_0>", locale); XMLValidatorErrorHandler errorHandler = new XMLValidatorErrorHandler(process); validator.setErrorHandler(errorHandler); try { validator.validate(xml); } catch (SAXParseException | IOException e) { <START> Exceptions.ignore(e); <END> } return !errorHandler.errorOccurred(); }</code><technical_language>Error handler handle SAXParseException. swallow IOExceptions here</technical_language>

Target:
public boolean validate(Source xml, Source xsd) throws SAXException { SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory.newSchema(xsd); Validator validator = schema.newValidator(); String language = UserContext.getCurrentUser().getLang(); Locale locale = Strings.areEqual(language, "en") ? Locale.ROOT : new Locale(language); validator.setProperty("<LINK_0>", locale); XMLValidatorErrorHandler errorHandler = new XMLValidatorErrorHandler(process); validator.setErrorHandler(errorHandler); try { validator.validate(xml); } catch (SAXParseException e) { Exceptions.ignore(e); } catch (IOException e) { process.log(ProcessLog.error().withMessage(e.getMessage())); return false; } return !errorHandler.errorOccurred(); }
Source:
<code>private final void fireParameterTypeChanged(final ParameterTypeEvent event) { if (event == null) { throw new NullPointerException( "Cannot send a null event to listeners."); } if (!isListenerAttached()) { return; } final Object[] listeners = getListeners(); for (Object <START> listener2 : <END> listeners) { final IParameterTypeListener listener = (IParameterTypeListener) listener2; listener.parameterTypeChanged(event); } }</code><technical_language>rename</technical_language>

Target:
private final void fireParameterTypeChanged(final ParameterTypeEvent event) { if (event == null) { throw new NullPointerException( "Cannot send a null event to listeners."); } if (!isListenerAttached()) { return; } final Object[] listeners = getListeners(); for (Object listener : listeners) { final IParameterTypeListener parameterTypeListener = (IParameterTypeListener) listener; parameterTypeListener.parameterTypeChanged(event); } }
Source:
<code>public ViewBinder(@NonNull final RepositoriesView view, @NonNull final RepositoriesViewModel viewModel) { <START> this.view = view; <END> this.viewModel = viewModel; }</code><technical_language>assert is null</technical_language>

Target:
public ViewBinder(@NonNull final RepositoriesView view, @NonNull final RepositoriesViewModel viewModel) { Preconditions.checkNotNull(view, "View cannot be null."); Preconditions.checkNotNull(viewModel, "ViewModel cannot be null."); this.view = view; this.viewModel = viewModel; }
Source:
<code><START> public Quantity(double value) { <END> this(value, UNKNOWN_UNITS); }</code><technical_language>is this constructor deprecated</technical_language>

Target:
public Quantity(double value) { this.value = value; }
Source:
<code>protected void map(AvroKey<DocumentText> key, NullWritable value, Context context) throws IOException, InterruptedException { DocumentText nlm = key.datum(); if (!StringUtils.isBlank(nlm.getText())) { final ExtractedDocumentMetadata.Builder output = ExtractedDocumentMetadata.newBuilder(); output.setId(nlm.getId()); try { SAXParserFactory saxFactory = SAXParserFactory.newInstance(); saxFactory.setValidating(false); SAXParser saxParser = saxFactory.newSAXParser(); XMLReader reader = saxParser.getXMLReader(); reader.setFeature("<LINK_2>", false); reader.setFeature("<LINK_0>", false); reader.setFeature("<LINK_1>", false); PmcXmlHandler pmcXmlHandler = new PmcXmlHandler(output); saxParser.parse(new InputSource( new StringReader(nlm.getText().toString())), pmcXmlHandler); mos.write(namedOutputMeta, new AvroKey<ExtractedDocumentMetadata>(output.build())); } catch (ParserConfigurationException e) { Map<CharSequence, CharSequence> auditSupplementaryData = new HashMap<CharSequence, CharSequence>(); auditSupplementaryData.put(FAULT_TEXT, nlm.getText()); mos.write(namedOutputFault, new AvroKey<Fault>(FaultUtils.exceptionToFault(nlm.getId(), e, auditSupplementaryData))); <START> } catch (SAXException e) { <END> Map<CharSequence, CharSequence> auditSupplementaryData = new HashMap<CharSequence, CharSequence>(); auditSupplementaryData.put(FAULT_TEXT, nlm.getText()); mos.write(namedOutputFault, new AvroKey<Fault>(FaultUtils.exceptionToFault(nlm.getId(), e, auditSupplementaryData))); } } }</code><technical_language>Indentation of code section is deep</technical_language>

Target:
protected void map(AvroKey<DocumentText> key, NullWritable value, Context context) throws IOException, InterruptedException { DocumentText nlm = key.datum(); if (!StringUtils.isBlank(nlm.getText())) { final ExtractedDocumentMetadata.Builder output = ExtractedDocumentMetadata.newBuilder(); output.setId(nlm.getId()); try { SAXParserFactory saxFactory = SAXParserFactory.newInstance(); saxFactory.setValidating(false); SAXParser saxParser = saxFactory.newSAXParser(); XMLReader reader = saxParser.getXMLReader(); reader.setFeature("<LINK_2>", false); reader.setFeature("<LINK_0>", false); reader.setFeature("<LINK_1>", false); PmcXmlHandler pmcXmlHandler = new PmcXmlHandler(output); saxParser.parse(new InputSource(new StringReader(nlm.getText().toString())), pmcXmlHandler); mos.write(namedOutputMeta, new AvroKey<ExtractedDocumentMetadata>(output.build())); } catch (ParserConfigurationException e) { handleException(nlm, e); } catch (SAXException e) { handleException(nlm, e); } } }
Source:
<code>static List<BlackboardArtifact> getArtifacts(SleuthkitCase skCase, BlackboardArtifact.Type artifactType, DataSource dataSource, BlackboardAttribute.Type attributeType, SortOrder sortOrder, int maxCount) throws TskCoreException { if (maxCount < 1 && maxCount != -1) { throw new IllegalArgumentException("Invalid maxCount passed to getArtifacts, value must be at greater 0"); } <START> TreeMap<BlackboardAttribute, BlackboardArtifact> sortedMap = new TreeMap<>(new AttributeComparator(sortOrder)); <END> List<BlackboardArtifact> artifactList = skCase.getBlackboard().getArtifacts(artifactType.getTypeID(), dataSource.getId()); for (BlackboardArtifact artifact : artifactList) { BlackboardAttribute attribute = artifact.getAttribute(attributeType); if (attribute != null) { sortedMap.put(attribute, artifact); } } artifactList = new ArrayList<>(); for (BlackboardArtifact artifact : sortedMap.values()) { artifactList.add(artifact); if (maxCount != -1 && artifactList.size() == maxCount - 1) { break; } } return artifactList; }</code><technical_language>I this need a data structure. Right now, artifacts a null for attribute sorted removed. Also, if items sort value, I is stored</technical_language>

Target:
static List<BlackboardArtifact> getArtifacts(SleuthkitCase skCase, BlackboardArtifact.Type artifactType, DataSource dataSource, BlackboardAttribute.Type attributeType, SortOrder sortOrder, int maxCount) throws TskCoreException { if (maxCount < 0) { throw new IllegalArgumentException("Invalid maxCount passed to getArtifacts, value must be equal to or greater than 0"); } return createListFromMap(getArtifactMap(skCase, artifactType, dataSource, attributeType, sortOrder), maxCount); }
Source:
<code><START> private void addAgentsProvidedServers(MachineImpl machine, List<String> agentKeys) throws ServerException { <END> for (String agentKey : agentKeys) { try { AgentImpl agent = new AgentImpl(agentRegistry.getAgent(AgentKeyImpl.parse(agentKey))); for (ServerConf2 conf2 : agent.getServers()) { Map<String, String> properties = conf2.getProperties(); ServerConfImpl conf = new ServerConfImpl(properties.get("ref"), conf2.getPort(), conf2.getProtocol(), properties.get("path")); machine.getConfig().getServers().add(conf); } } catch (AgentException e) { throw new ServerException(e); } } }</code><technical_language>this code is tested</technical_language>

Target:
private void addAgentsProvidedServers(MachineImpl machine, List<String> agentKeys) throws ServerException { for (String agentKey : agentKeys) { try { AgentImpl agent = new AgentImpl(agentRegistry.getAgent(AgentKeyImpl.parse(agentKey))); for (Map.Entry<String, ? extends ServerConf2> entry : agent.getServers().entrySet()) { String ref = entry.getKey(); ServerConf2 conf2 = entry.getValue(); ServerConfImpl conf = new ServerConfImpl(ref, conf2.getPort(), conf2.getProtocol(), conf2.getProperties().get("path")); machine.getConfig().getServers().add(conf); } } catch (AgentException e) { throw new ServerException(e); } } }
Source:
<code>public RequestHeader(Struct struct, short headerVersion) { this.data = new RequestHeaderData(struct, headerVersion); <START> this.headerVersion = headerVersion; <END> }</code><technical_language>nit: replace this(new RequestHeaderData(struct, headerVersion), headerVersion). Consolidates c'tor logic place</technical_language>

Target:
public RequestHeader(Struct struct, short headerVersion) { this(new RequestHeaderData(struct, headerVersion), headerVersion); }
Source:
<code>public void testHetSensDistributions() throws Exception { final double tolerance = 0.02; final double expectedResult = .9617; <START> final int max = 500; <END> final double depthDistribution = new double[max+1]; final double qualityDistribution = new double[50]; final Scanner scanDepth = new Scanner(depth); int i = 0; while (scanDepth.hasNextDouble()) { depthDistribution[i] = scanDepth.nextDouble(); i++; } final Scanner scanBaseQ = new Scanner(baseQ); int j = 0; while (scanBaseQ.hasNextDouble()) { qualityDistribution[j] = scanBaseQ.nextDouble(); j++; } final int sampleSize = 1000; final double logOddsThreshold = 3.0; final double result = TheoreticalSensitivity.hetSNPSensitivity(depthDistribution, qualityDistribution, sampleSize, logOddsThreshold); Assert.assertEquals(result, expectedResult, tolerance); }</code><technical_language>Rename maxDepth</technical_language>

Target:
public void testHetSensDistributions() throws Exception { final double tolerance = 0.02; final double expectedResult = .9617; final int maxDepth = 500; final double depthDistribution = new double[maxDepth+1]; final double qualityDistribution = new double[50]; final Scanner scanDepth = new Scanner(DEPTH); for (int i = 0; scanDepth.hasNextDouble(); i++) { depthDistribution[i] = scanDepth.nextDouble(); } final Scanner scanBaseQ = new Scanner(BASEQ); for (int j = 0; scanBaseQ.hasNextDouble(); j++) { qualityDistribution[j] = scanBaseQ.nextDouble(); } final int sampleSize = 1000; final double logOddsThreshold = 3.0; final double result = TheoreticalSensitivity.hetSNPSensitivity(depthDistribution, qualityDistribution, sampleSize, logOddsThreshold); Assert.assertEquals(result, expectedResult, tolerance); }
Source:
<code>private void addTypeParameters(CompilationUnitRewrite imRewrite, List<TypeParameter> list, ITypeBinding parent, ImportRewriteContext context) { ITypeBinding enclosing= parent.getDeclaringClass(); if (enclosing != null) addTypeParameters(imRewrite, list, enclosing, context); ITypeBinding[] typeParameters= parent.getTypeParameters(); for (ITypeBinding typeParameter : typeParameters) { TypeParameter ntp= imRewrite.getAST().newTypeParameter(); ntp.setName(imRewrite.getAST().newSimpleName(typeParameter.getName())); <START> ITypeBinding[] bounds = typeParameter.getTypeBounds(); <END> for (ITypeBinding bound : bounds) { if (!"java.lang.Object".equals(bound.getQualifiedName())) { ntp.typeBounds().add(imRewrite.getImportRewrite().addImport(bound, imRewrite.getAST(), context, TypeLocation.TYPE_BOUND)); } } list.add(ntp); } }</code><technical_language>fix =</technical_language>

Target:
private void addTypeParameters(CompilationUnitRewrite imRewrite, List<TypeParameter> list, ITypeBinding parent, ImportRewriteContext context) { ITypeBinding enclosing= parent.getDeclaringClass(); if (enclosing != null) addTypeParameters(imRewrite, list, enclosing, context); for (ITypeBinding typeParameter : parent.getTypeParameters()) { TypeParameter ntp= imRewrite.getAST().newTypeParameter(); ntp.setName(imRewrite.getAST().newSimpleName(typeParameter.getName())); for (ITypeBinding bound : typeParameter.getTypeBounds()) { if (!"java.lang.Object".equals(bound.getQualifiedName())) { ntp.typeBounds().add(imRewrite.getImportRewrite().addImport(bound, imRewrite.getAST(), context, TypeLocation.TYPE_BOUND)); } } list.add(ntp); } }
Source:
<code>public void testStatsCalculatorUsesLayout() { assertPlan("SELECT orderstatus FROM orders WHERE orderstatus = 'P'", anyTree( node(TableScanNode.class) .withStats(PlanNodeStatsEstimate.builder() .setOutputRowCount(new Estimate(363.0)) .setOutputSizeInBytes(unknownValue()) .build()))); assertPlan("SELECT orderstatus FROM orders WHERE orderkey = 42", anyTree( node(TableScanNode.class) .withStats(PlanNodeStatsEstimate.builder() .setOutputRowCount(new Estimate(15000.0)) .setOutputSizeInBytes(unknownValue()) .build()))); <START> } <END></code><technical_language>unrelated</technical_language>

Target:
public void testStatsCalculatorUsesLayout() { assertPlan("SELECT orderstatus FROM orders WHERE orderstatus = 'P'", anyTree( node(TableScanNode.class) .withStats(PlanNodeStatsEstimate.builder() .setOutputRowCount(363.0) .build()))); assertPlan("SELECT orderstatus FROM orders WHERE orderkey = 42", anyTree( node(TableScanNode.class) .withStats(PlanNodeStatsEstimate.builder() .setOutputRowCount(15000.0) .build()))); }
Source:
<code>public RibbonLoadBalancedRetryPolicy(String serviceId, RibbonLoadBalancerContext context, ServiceInstanceChooser loadBalanceChooser, IClientConfig clientConfig) { this.serviceId = serviceId; this.lbContext = context; this.loadBalanceChooser = loadBalanceChooser; String retryableStatusCodesProp = clientConfig.getPropertyAsString(RETRYABLE_STATUS_CODES, ""); String[] retryableStatusCodesArray = retryableStatusCodesProp.split(","); for(String code : retryableStatusCodesArray) { if(!StringUtils.isEmpty(code)) { try { retryableStatusCodes.add(Integer.valueOf(code.trim())); } catch (NumberFormatException e) { <START> log.warn("Can't add status code: " + code, e); <END> } } } }</code><technical_language>I a more accurate warning message here. add status code code converted integer</technical_language>

Target:
public RibbonLoadBalancedRetryPolicy(String serviceId, RibbonLoadBalancerContext context, ServiceInstanceChooser loadBalanceChooser, IClientConfig clientConfig) { this.serviceId = serviceId; this.lbContext = context; this.loadBalanceChooser = loadBalanceChooser; String retryableStatusCodesProp = clientConfig.getPropertyAsString(RETRYABLE_STATUS_CODES, ""); String[] retryableStatusCodesArray = retryableStatusCodesProp.split(","); for(String code : retryableStatusCodesArray) { if(!StringUtils.isEmpty(code)) { try { retryableStatusCodes.add(Integer.valueOf(code.trim())); } catch (NumberFormatException e) { log.warn("We cant add the status code because the code [ " + code + " ] could not be converted to an integer. ", e); } } } }
Source:
<code>private void writeToFile(String fileName, String fileContent) { try { File file = new File(fileName); if (!file.exists()) { file.createNewFile(); } try (FileWriter fw = new FileWriter(file.getAbsoluteFile()); <START> BufferedWriter bw = new BufferedWriter(fw)) { <END> bw.write(fileContent); } } catch (IOException e) { e.printStackTrace(); } }</code><technical_language>This is ok more compact: java try (BufferedWriter bw = new BufferedWriter(new FileWriter(file.getAbsoluteFile()))) {</technical_language>

Target:
private void writeToFile(String fileName, String fileContent) { try { File file = new File(fileName); if (!file.exists()) { file.createNewFile(); } try (BufferedWriter bw = new BufferedWriter(new FileWriter(file.getAbsoluteFile()))) { bw.write(fileContent); } } catch (IOException e) { e.printStackTrace(); } }
Source:
<code>public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (isAuthenticated() && ((HttpServletRequest) request).getRequestURI().equals("/loginUser")) { String encodedRedirectURL = ((HttpServletResponse) response).encodeRedirectURL( ((HttpServletRequest) request).getContextPath() + "/userMainPage"); <START> ((HttpServletResponse) response).setStatus(HttpStatus.SC_TEMPORARY_REDIRECT); <END> ((HttpServletResponse) response).setHeader("Location", encodedRedirectURL); } chain.doFilter(request, response); }</code><technical_language>promote variables cast</technical_language>

Target:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest servletRequest = (HttpServletRequest) request; HttpServletResponse servletResponse = (HttpServletResponse) response; if (isAuthenticated() && "/loginUser".equals(servletRequest.getRequestURI())) { String encodedRedirectURL = ((HttpServletResponse) response).encodeRedirectURL( servletRequest.getContextPath() + "/userMainPage"); servletResponse.setStatus(HttpStatus.SC_TEMPORARY_REDIRECT); servletResponse.setHeader("Location", encodedRedirectURL); } chain.doFilter(servletRequest, servletResponse); }
Source:
<code>public WiringPage() { <START> init(); <END> }</code><technical_language>this included (doesn't sense method if else); real good refactoring of this class</technical_language>

Target:
public WiringPage() { initializeDomainChooseForm(); initializeGlobalNameField(); initializeInstanceIdField(); initializeGlobals(); initializeEndpoints(); initializeWiringForm(); initializeFeedbackPanel(); }
Source:
<code><START> protected void setId(String id) { <END> this.id = id; }</code><technical_language>Oh! No! introduced this setter :innocent: public avoid MutableCorrelationData if (this.correlationData != null) { in CorrelationMessagePostProcessor? tired mind nit-pick..</technical_language>

Target:
public void setId(String id) { this.id = id; }
Source:
<code>public void initialize(Config newConfig) { super.initialize(newConfig); this.config = newConfig; this.connectionString = Context.stateManagerConnectionString(newConfig); this.isSchedulerService = Context.schedulerService(newConfig); this.tunnelProcesses = new ArrayList<>(); NetworkUtils.TunnelConfig tunnelConfig = NetworkUtils.TunnelConfig.build(config, NetworkUtils.HeronSystem.STATE_MANAGER); if (tunnelConfig.isTunnelNeeded()) { for (int setupCount = 0;; ++setupCount) { Pair<String, List<Process>> tunneledResults = setupZkTunnel(tunnelConfig); String newConnectionString = tunneledResults.first; if (newConnectionString.isEmpty()) { if (setupCount < TUNNEL_SETUP_RETRY) { <START> continue; END> } else { throw new IllegalArgumentException("Failed to connect to tunnel host '" + tunnelConfig.getTunnelHost() + "'"); } } connectionString = newConnectionString; tunnelProcesses.addAll(tunneledResults.second); } } client = getCuratorClient(); LOG.info("Starting Curator client connecting to: " + connectionString); client.start(); try { if (!client.blockUntilConnected(ZkContext.connectionTimeoutMs(newConfig), TimeUnit.MILLISECONDS)) { throw new RuntimeException("Failed to initialize CuratorClient"); } } catch (InterruptedException e) { throw new RuntimeException("Failed to initialize CuratorClient", e); } if (ZkContext.isInitializeTree(newConfig)) { initTree(); } }</code><technical_language>wait for some time another retry more favorable</technical_language>

Target:
public void initialize(Config newConfig) { super.initialize(newConfig); this.config = newConfig; this.connectionString = Context.stateManagerConnectionString(newConfig); this.isSchedulerService = Context.schedulerService(newConfig); this.tunnelProcesses = new ArrayList<>(); NetworkUtils.TunnelConfig tunnelConfig = NetworkUtils.TunnelConfig.build(config, NetworkUtils.HeronSystem.STATE_MANAGER); if (tunnelConfig.isTunnelNeeded()) { for (int setupCount = 0;; ++setupCount) { Pair<String, List<Process>> tunneledResults = setupZkTunnel(tunnelConfig); String newConnectionString = tunneledResults.first; if (!newConnectionString.isEmpty()) { connectionString = newConnectionString; tunnelProcesses.addAll(tunneledResults.second); break; } else { if (setupCount < TUNNEL_SETUP_RETRY) { try { TimeUnit.SECONDS.sleep(TUNNEL_SETUP_RETRY_SLEEP_SEC); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } } else { throw new IllegalArgumentException("Failed to connect to tunnel host '" + tunnelConfig.getTunnelHost() + "'"); } } } } client = getCuratorClient(); LOG.info("Starting Curator client connecting to: " + connectionString); client.start(); try { if (!client.blockUntilConnected(ZkContext.connectionTimeoutMs(newConfig), TimeUnit.MILLISECONDS)) { throw new RuntimeException("Failed to initialize CuratorClient"); } } catch (InterruptedException e) { throw new RuntimeException("Failed to initialize CuratorClient", e); } if (ZkContext.isInitializeTree(newConfig)) { initTree(); } }
Source:
<code>public void testChangeNotify(TestHarness th) throws IOException { DataEncoder dataEncoder = new DataEncoder("Conv-BEB"); dataEncoder.putStart(14, "event"); dataEncoder.put(13, "name", "Query"); dataEncoder.putStart(15, "subscriptions"); dataEncoder.put(10, "battery", "Disable"); dataEncoder.put(10, "wifi_status", "Enable"); dataEncoder.put(10, "network_status", "Enable"); dataEncoder.putEnd(15, "subscriptions"); dataEncoder.putEnd(14, "event"); byte[] sendData = dataEncoder.getData(); client.send(sendData, 0, sendData.length); sendFakeOnlineEvent(); LocalMessageProtocolMessage msg = client.newMessage(null); client.receive(msg); byte[] clientData = msg.getData(); DataDecoder dataDecoder = new DataDecoder("Conv-BEB", clientData, 0, clientData.length); dataDecoder.getStart(14); th.check(dataDecoder.getString(13), "ChangeNotify"); dataDecoder.getString(10); dataDecoder.getStart(15); th.check(dataDecoder.getName(), "network_status"); dataDecoder.getStart(14); th.check(dataDecoder.getString(10), "Home"); <START> dataDecoder.getEnd(14); <END> dataDecoder.getEnd(15); msg = client.newMessage(null); client.receive(msg); clientData = msg.getData(); dataDecoder = new DataDecoder("Conv-BEB", clientData, 0, clientData.length); dataDecoder.getStart(14); th.check(dataDecoder.getString(13), "ChangeNotify"); dataDecoder.getString(10); dataDecoder.getStart(15); th.check(dataDecoder.getName(), "wifi_status"); dataDecoder.getStart(14); th.check(dataDecoder.getBoolean(), true); dataDecoder.getEnd(14); dataDecoder.getEnd(15); }</code><technical_language>check boolean well</technical_language>

Target:
public void testChangeNotify(TestHarness th) throws IOException { DataEncoder dataEncoder = new DataEncoder("Conv-BEB"); dataEncoder.putStart(14, "event"); dataEncoder.put(13, "name", "Query"); dataEncoder.putStart(15, "subscriptions"); dataEncoder.put(10, "battery", "Disable"); dataEncoder.put(10, "wifi_status", "Enable"); dataEncoder.put(10, "network_status", "Enable"); dataEncoder.putEnd(15, "subscriptions"); dataEncoder.putEnd(14, "event"); byte[] sendData = dataEncoder.getData(); client.send(sendData, 0, sendData.length); sendFakeOnlineEvent(); testNotify(th, true); sendFakeOfflineEvent(); testNotify(th, false); }
Source:
<code>protected boolean canDoAction() { if (!super.canDoAction()) { return false; } if (getMissingServerHooks().isEmpty()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_HOOK_NO_CONFLICT_SERVERS); return false; } for (GlusterServerHook serverHook: getMissingServerHooks()) { VDS vds = getVdsDAO().get(serverHook.getServerId()); if (vds == null || vds.getStatus() != VDSStatus.Up) { <START> setVdsName(vds != null ? vds.getName() : "No Server"); <END> addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_SERVER_STATUS_NOT_UP); return false; } } return true; }</code><technical_language>Check if needs "NO SERVER" in case vds is null well</technical_language>

Target:
protected boolean canDoAction() { if (!super.canDoAction()) { return false; } if (getMissingServerHooks().isEmpty()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_HOOK_NO_CONFLICT_SERVERS); return false; } for (GlusterServerHook serverHook: getMissingServerHooks()) { VDS vds = getVdsDAO().get(serverHook.getServerId()); if (vds == null || vds.getStatus() != VDSStatus.Up) { setVdsName(vds != null ? vds.getName() : "NO SERVER"); addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_SERVER_STATUS_NOT_UP); return false; } } return true; }