auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final LayoutInflater inflater = LayoutInflater.from(getActivity()); ViewHolder holder; final LinearLayout parent = (LinearLayout) view.findViewById(R.id.root); holder = createViewHolder(inflater, parent); holder.typeView.setIcon(FontAwesomeIcons.fa_file_text_o); holder.titleView.setText(R.string.handouts_title); holder.subtitleView.setText(R.string.handouts_subtitle); holder.rowView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (courseData != null) { environment.getRouter().showHandouts(getActivity(), courseData); } } }); holder = createViewHolder(inflater, parent); holder.typeView.setIcon(FontAwesomeIcons.fa_bullhorn); holder.titleView.setText(R.string.announcement_title); holder.subtitleView.setText(R.string.announcement_subtitle); holder.rowView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (courseData != null) { environment.getRouter().showCourseAnnouncement(getActivity(), courseData); } } }); }

Target:
public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final LayoutInflater inflater = LayoutInflater.from(getActivity()); final LinearLayout parent = (LinearLayout) view.findViewById(R.id.root); ViewHolder holder; holder = createViewHolder(inflater, parent); holder.typeView.setIcon(FontAwesomeIcons.fa_file_text_o); holder.titleView.setText(R.string.handouts_title); holder.subtitleView.setText(R.string.handouts_subtitle); holder.rowView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (courseData != null) { environment.getRouter().showHandouts(getActivity(), courseData); } } }); holder = createViewHolder(inflater, parent); holder.typeView.setIcon(FontAwesomeIcons.fa_bullhorn); holder.titleView.setText(R.string.announcement_title); holder.subtitleView.setText(R.string.announcement_subtitle); holder.rowView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (courseData != null) { environment.getRouter().showCourseAnnouncement(getActivity(), courseData); } } }); }
Source:
public PollerFlux<OperationResult, List<FormPage>> beginRecognizeContent(Flux<ByteBuffer> form, long length, RecognizeOptions recognizeOptions) { try { Objects.requireNonNull(form, "'form' is required and cannot be null."); recognizeOptions = getRecognizeOptionsProperties(recognizeOptions); return new PollerFlux<>( recognizeOptions.getPollInterval(), streamActivationOperation( contentType -> service.analyzeLayoutAsyncWithResponseAsync(contentType, form, length) .map(response -> new OperationResult( parseModelId(response.getDeserializedHeaders().getOperationLocation()))), form, recognizeOptions.getContentType()), pollingOperation(service::getAnalyzeLayoutResultWithResponseAsync), (activationResponse, context) -> monoError(logger, new RuntimeException("Cancellation is not supported")), fetchExtractContentResult()); } catch (RuntimeException ex) { return PollerFlux.error(ex); } }

Target:
public PollerFlux<OperationResult, List<FormPage>> beginRecognizeContent(Flux<ByteBuffer> form, long length, RecognizeOptions recognizeOptions) { return beginRecognizeContent(form, length, recognizeOptions, Context.NONE); }
Source:
public void cachesGetRequest() throws Exception { final Map<String, String> headers = Collections.singletonMap( LastModifiedCachingWire.LAST_MODIFIED, LastModifiedCachingWireTest.LONG_AGO ); final MkContainer container = new MkGrizzlyContainer() .next( new MkAnswer.Simple( HttpURLConnection.HTTP_OK, headers.entrySet(), new byte[0] ) ) .next( new MkAnswer.Simple(HttpURLConnection.HTTP_NOT_MODIFIED), new IsAnything<MkQuery>(), Tv.TEN ).start(); try { final Request req = new JdkRequest(container.home()) .through(LastModifiedCachingWire.class); for (int idx = 0; idx < Tv.TEN; ++idx) { req.fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK); } } finally { container.stop(); } MatcherAssert.assertThat( container.queries(), Matchers.equalTo(Tv.TEN) ); }

Target:
public void cachesGetRequest() throws Exception { final Map<String, String> headers = Collections.singletonMap( LastModifiedCachingWire.LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT" ); final MkContainer container = new MkGrizzlyContainer() .next( new MkAnswer.Simple( HttpURLConnection.HTTP_OK, headers.entrySet(), LastModifiedCachingWireTest.BODY.getBytes() ) ) .next( new MkAnswer.Simple(HttpURLConnection.HTTP_NOT_MODIFIED), new IsAnything<MkQuery>(), Tv.TEN ).start(); try { final Request req = new JdkRequest(container.home()) .through(LastModifiedCachingWire.class); for (int idx = 0; idx < Tv.TEN; ++idx) { req.fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .assertBody( Matchers.equalTo(LastModifiedCachingWireTest.BODY) ); } MatcherAssert.assertThat( container.queries(), Matchers.equalTo(Tv.TEN) ); } finally { container.stop(); } }
Source:
public Image getImage(MUILabel element) { return getImage(element, false); }

Target:
public Image getImage(MUILabel element) { Image image = (Image) ((MUIElement) element).getTransientData().get( IPresentationEngine.OVERRIDE_ICON_IMAGE_KEY); if (image == null || image.isDisposed()) { image = getImageFromURI(getIconURI(element)); } if (image != null) { image = adornImage((MUIElement) element, image); } return image; }
Source:
public void shouldCreateFailureTryWithResources7() { final Resource<Integer> resource1 = resource(1); final Resource<Integer> resource2 = resource(2); final Resource<Integer> resource3 = resource(3); final Resource<Integer> resource4 = resource(4); final Resource<Integer> resource5 = resource(5); final Resource<Integer> resource6 = resource(6); final Resource<Integer> resource7 = resource(7); final Try<?> actual = Try.withResources(() -> resource1, () -> resource2, () -> resource3, () -> resource4, () -> resource5, () -> resource6, () -> resource7).of((i1, i2, i3, i4, i5, i6, i7) -> { throw new Error(); }); assertThat(actual.isFailure()).isTrue(); assertThat(resource1.isClosed).isTrue(); assertThat(resource2.isClosed).isTrue(); assertThat(resource3.isClosed).isTrue(); assertThat(resource4.isClosed).isTrue(); assertThat(resource5.isClosed).isTrue(); assertThat(resource6.isClosed).isTrue(); assertThat(resource7.isClosed).isTrue(); }

Target:
public void shouldCreateFailureTryWithResources7() { final Closeable<Integer> closeable1 = Closeable.of(1); final Closeable<Integer> closeable2 = Closeable.of(2); final Closeable<Integer> closeable3 = Closeable.of(3); final Closeable<Integer> closeable4 = Closeable.of(4); final Closeable<Integer> closeable5 = Closeable.of(5); final Closeable<Integer> closeable6 = Closeable.of(6); final Closeable<Integer> closeable7 = Closeable.of(7); final Try<?> actual = Try.withResources(() -> closeable1, () -> closeable2, () -> closeable3, () -> closeable4, () -> closeable5, () -> closeable6, () -> closeable7).of((i1, i2, i3, i4, i5, i6, i7) -> { throw new Error(); }); assertThat(actual.isFailure()).isTrue(); assertThat(closeable1.isClosed).isTrue(); assertThat(closeable2.isClosed).isTrue(); assertThat(closeable3.isClosed).isTrue(); assertThat(closeable4.isClosed).isTrue(); assertThat(closeable5.isClosed).isTrue(); assertThat(closeable6.isClosed).isTrue(); assertThat(closeable7.isClosed).isTrue(); }
Source:
private Session getSession(URI sessionModelURI, boolean restore) { Session sessionFromURI; try { sessionFromURI = null; if (restore) { sessionFromURI = SessionManager.INSTANCE.getSession(sessionModelURI, new NullProgressMonitor()); } else { sessionFromURI = SessionManager.INSTANCE.getExistingSession(sessionModelURI); } if (sessionFromURI != null) { if (!sessionFromURI.isOpen()) { sessionFromURI.open(new NullProgressMonitor()); } IEditingSession uiSession = null; if (restore) { uiSession = SessionUIManager.INSTANCE.getOrCreateUISession(sessionFromURI); } else { uiSession = SessionUIManager.INSTANCE.getUISession(sessionFromURI); } if (uiSession != null && uiSession.isOpen()) { uiSession.open(); } } } catch (IllegalStateException e) { sessionFromURI = null; } catch (OperationCanceledException e) { sessionFromURI = null; } return sessionFromURI; }

Target:
private Session getSession(URI sessionModelURI, boolean restore) { Session sessionFromURI; try { sessionFromURI = null; if (restore) { sessionFromURI = SessionManager.INSTANCE.getSession(sessionModelURI, new NullProgressMonitor()); } else { sessionFromURI = SessionManager.INSTANCE.getExistingSession(sessionModelURI); } if (sessionFromURI != null) { if (!sessionFromURI.isOpen()) { sessionFromURI.open(new NullProgressMonitor()); } IEditingSession uiSession = null; if (restore) { uiSession = SessionUIManager.INSTANCE.getOrCreateUISession(sessionFromURI); } else { uiSession = SessionUIManager.INSTANCE.getUISession(sessionFromURI); } if (uiSession != null && !uiSession.isOpen()) { uiSession.open(); } } } catch (IllegalStateException e) { sessionFromURI = null; } catch (OperationCanceledException e) { sessionFromURI = null; } return sessionFromURI; }
Source:
private static List<IResource> collectRelatedChanges( IResource[] selectedResources, IWorkbenchPart part, IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { SubscriberScopeManager manager = GitScopeUtil.createScopeManager( selectedResources, SubMonitor.convert(monitor, 50)); GitScopeOperation buildScopeOperation = GitScopeOperationFactory .getFactory().createGitScopeOperation(part, manager); buildScopeOperation.run(SubMonitor.convert(monitor, 50)); return buildScopeOperation.getRelevantResources(); }

Target:
private static List<IResource> collectRelatedChanges( IResource[] selectedResources, IWorkbenchPart part, IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { SubMonitor progress = SubMonitor.convert(monitor, 2); SubscriberScopeManager manager = GitScopeUtil.createScopeManager( selectedResources, progress.newChild(1)); GitScopeOperation buildScopeOperation = GitScopeOperationFactory .getFactory().createGitScopeOperation(part, manager); buildScopeOperation.run(progress.newChild(1)); return buildScopeOperation.getRelevantResources(); }
Source:
public void open(IProgressMonitor monitor) throws RemoteConnectionException { if (!isOpen()) { checkIsConfigured(); SubMonitor subMon = SubMonitor.convert(monitor, 60); Session session = newSession(fManager.getUserAuthenticator(this), subMon.newChild(10)); if (subMon.isCanceled()) { throw new RemoteConnectionException(Messages.JSchConnection_Connection_was_cancelled); } loadEnv(subMon.newChild(10)); if (!checkConfiguration(session, subMon.newChild(20))) { newSession(fManager.getUserAuthenticator(this), subMon.newChild(10)); loadEnv(subMon.newChild(10)); } fIsOpen = true; try { fWorkingDir = getCwd(subMon.newChild(10)); loadProperties(subMon.newChild(10)); } catch (RemoteConnectionException e) { fIsOpen = false; throw e; } fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_OPENED); } }

Target:
public void open(IProgressMonitor monitor) throws RemoteConnectionException { if (!isOpen()) { checkIsConfigured(); SubMonitor subMon = SubMonitor.convert(monitor, 60); Session session = newSession(fManager.getUserAuthenticator(this), subMon.newChild(10)); if (subMon.isCanceled()) { throw new RemoteConnectionException(Messages.JSchConnection_Connection_was_cancelled); } fWorkingDir = getCwd(subMon.newChild(10)); if (!checkConfiguration(session, subMon.newChild(20))) { newSession(fManager.getUserAuthenticator(this), subMon.newChild(10)); loadEnv(subMon.newChild(10)); } fIsOpen = true; loadProperties(subMon.newChild(10)); fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_OPENED); } }
Source:
public HashMap setRoleTypesExpected() { this.unsetTypeExpected(); HashMap roleTypes = new HashMap(); roleTypes.put(1, TypeNames.STRING); roleTypes.put(2, TypeNames.INT); roleTypes.put(3, TypeNames.INT); roleTypes.put(4, TypeNames.INT); roleTypes.put(5, TypeNames.DATE); roleTypes.put(6, TypeNames.DATE); roleTypes.put(7, TypeNames.INT); roleTypes.put(8, TypeNames.STRING); return roleTypes; }

Target:
public HashMap setRoleTypesExpected() { HashMap roleTypes = new HashMap(); roleTypes.put(1, TypeNames.STRING); roleTypes.put(2, TypeNames.INT); roleTypes.put(3, TypeNames.INT); roleTypes.put(4, TypeNames.INT); roleTypes.put(5, TypeNames.DATE); roleTypes.put(6, TypeNames.DATE); roleTypes.put(7, TypeNames.INT); roleTypes.put(8, TypeNames.STRING); return roleTypes; }
Source:
protected boolean removeTransfer(InboundTransferTask inboundTransfer) { boolean found = false; synchronized (transferMapsLock) { if (trace) log.tracef("Removing inbound transfers from node %s for segments %s", inboundTransfer.getSegments(), inboundTransfer.getSource(), cacheName); List<InboundTransferTask> transfers = transfersBySource.get(inboundTransfer.getSource()); if (transfers != null && (found = transfers.remove(inboundTransfer)) && transfers.isEmpty()) { transfersBySource.remove(inboundTransfer.getSource()); } inboundTransfer.getSegments().forEach((Integer segment) -> { List<InboundTransferTask> innerTransfers = transfersBySegment.get(segment); if (innerTransfers != null && innerTransfers.remove(inboundTransfer) && innerTransfers.isEmpty()) { transfersBySegment.remove(segment); } }); } return found; }

Target:
protected boolean removeTransfer(InboundTransferTask inboundTransfer) { boolean found = false; synchronized (transferMapsLock) { if (trace) log.tracef("Removing inbound transfers from node %s for segments %s", inboundTransfer.getSegments(), inboundTransfer.getSource(), cacheName); List<InboundTransferTask> transfers = transfersBySource.get(inboundTransfer.getSource()); if (transfers != null && (found = transfers.remove(inboundTransfer)) && transfers.isEmpty()) { transfersBySource.remove(inboundTransfer.getSource()); } for (Integer segment : inboundTransfer.getSegments()) { List<InboundTransferTask> innerTransfers = transfersBySegment.get(segment); if (innerTransfers != null && innerTransfers.remove(inboundTransfer) && innerTransfers.isEmpty()) { transfersBySegment.remove(segment); } } } return found; }
Source:
public EnglishLowerCase(final String string) { this.value = string.toLowerCase(EnglishLowerCase.ENGLISH); }

Target:
public EnglishLowerCase(final String string) { this.value = string; }
Source:
protected ICommand getCreateCommand(CreateElementRequest req) { EObject owner = req.getContainer(); EReference eref = req.getContainmentFeature(); if (eref == null) { return UnexecutableCommand.INSTANCE; } if (owner instanceof Component && eref == UMLPackage.eINSTANCE.getClass_NestedClassifier() && req.getElementType().getEClass() == UMLPackage.eINSTANCE.getComponent()) { return UnexecutableCommand.INSTANCE; } return super.getCreateCommand(req); }

Target:
protected ICommand getCreateCommand(CreateElementRequest req) { EObject owner = req.getContainer(); EReference eref = req.getContainmentFeature(); if (owner instanceof Component && eref == UMLPackage.eINSTANCE.getClass_NestedClassifier() && req.getElementType().getEClass() == UMLPackage.eINSTANCE.getComponent()) { return UnexecutableCommand.INSTANCE; } return super.getCreateCommand(req); }
Source:
private void getColumnEncryptionProperties(String[] path, Map<ColumnPath, ColumnEncryptionProperties> columnPropertyMap, Configuration conf) throws ParquetCryptoRuntimeException { String pathName = String.join(".", path); String columnKeyName = conf.get(pathName, null); if (columnKeyName != null) { ColumnPath columnPath = ColumnPath.get(path); ColumnEncryptionProperties colEncProp = ColumnEncryptionProperties.builder(columnPath) .withKey(COL_KEY) .withKeyMetaData(COL_KEY_METADATA) .build(); columnPropertyMap.put(columnPath, colEncProp); } }

Target:
private void getColumnEncryptionProperties(String[] path, Map<ColumnPath, ColumnEncryptionProperties> columnPropertyMap, Configuration conf) throws ParquetCryptoRuntimeException { String pathName = String.join(".", path); String columnKeyName = conf.get(PATH_NAME_PREFIX + pathName, null); if (columnKeyName != null) { ColumnPath columnPath = ColumnPath.get(path); ColumnEncryptionProperties colEncProp = ColumnEncryptionProperties.builder(columnPath) .withKey(COL_KEY) .withKeyMetaData(COL_KEY_METADATA) .build(); columnPropertyMap.put(columnPath, colEncProp); } }
Source:
void reportInternalBugsnagError(@NonNull Error error) { error.setAppData(appData.getAppDataSummary()); error.setDeviceData(deviceData.getDeviceDataSummary()); MetaData metaData = error.getMetaData(); Notifier notifier = Notifier.getInstance(); metaData.addToTab(INTERNAL_DIAGNOSTICS_TAB, "notifierName", notifier.getName()); metaData.addToTab(INTERNAL_DIAGNOSTICS_TAB, "notifierVersion", notifier.getVersion()); metaData.addToTab(INTERNAL_DIAGNOSTICS_TAB, "apiKey", config.getApiKey()); Object packageName = appData.getAppData().get("packageName"); metaData.addToTab(INTERNAL_DIAGNOSTICS_TAB, "packageName", packageName); final Report report = new Report(null, error); try { Async.run(new Runnable() { @Override public void run() { try { Delivery delivery = config.getDelivery(); if (delivery instanceof DefaultDelivery) { Map<String, String> headers = config.getErrorApiHeaders(); headers.put("Bugsnag-Internal-Error", "true"); headers.remove(Configuration.HEADER_API_KEY); DefaultDelivery defaultDelivery = (DefaultDelivery) delivery; defaultDelivery.deliver(config.getEndpoint(), report, headers); } } catch (Exception exception) { Logger.warn("Failed to report minimal error to Bugsnag", exception); } } }); } catch (RejectedExecutionException ignored) { } }

Target:
void reportInternalBugsnagError(@NonNull Error error) { error.setAppData(appData.getAppDataSummary()); error.setDeviceData(deviceData.getDeviceDataSummary()); MetaData metaData = error.getMetaData(); Notifier notifier = Notifier.getInstance(); metaData.addToTab(INTERNAL_DIAGNOSTICS_TAB, "notifierName", notifier.getName()); metaData.addToTab(INTERNAL_DIAGNOSTICS_TAB, "notifierVersion", notifier.getVersion()); metaData.addToTab(INTERNAL_DIAGNOSTICS_TAB, "apiKey", config.getApiKey()); Object packageName = appData.getAppData().get("packageName"); metaData.addToTab(INTERNAL_DIAGNOSTICS_TAB, "packageName", packageName); final Report report = new Report(null, error); try { Async.run(new Runnable() { @Override public void run() { try { Delivery delivery = config.getDelivery(); if (delivery instanceof DefaultDelivery) { Map<String, String> headers = config.getErrorApiHeaders(); headers.put("Bugsnag-Internal-Error", "true"); headers.remove(Configuration.HEADER_API_KEY); DefaultDelivery defaultDelivery = (DefaultDelivery) delivery; defaultDelivery.deliver(config.getEndpoint(), report, headers); } } catch (Exception exception) { Logger.warn("Failed to report internal error to Bugsnag", exception); } } }); } catch (RejectedExecutionException ignored) { } }
Source:
public void widgetSelected(SelectionEvent e) { Table table = fTableViewer.getTable(); TableColumn prevSortcolumn = table.getSortColumn(); if (prevSortcolumn == fColumn) { flipSortDirection(); } table.setSortDirection(fDirection); table.setSortColumn(fColumn); Comparator<T> comparator; if (fDirection == SWT.DOWN) { comparator = fComparator; } else { comparator = checkNotNull(Collections.reverseOrder(fComparator)); } IContentProvider contentProvider = fTableViewer.getContentProvider(); if (contentProvider instanceof DeferredContentProvider) { DeferredContentProvider deferredContentProvider = (DeferredContentProvider) contentProvider; deferredContentProvider.setSortOrder(comparator); } else if (contentProvider instanceof ISortingLazyContentProvider) { long columnId = (long) fColumn.getData(COLUMN_ID_KEY); ISortingLazyContentProvider sortingLazyContentProvider = (ISortingLazyContentProvider) contentProvider; sortingLazyContentProvider.setSortOrder(columnId, fDirection == SWT.DOWN ? true : false); } else { fTableViewer.setComparator(new ElementComparator<>(comparator)); } }

Target:
public void widgetSelected(SelectionEvent e) { Table table = fTableViewer.getTable(); TableColumn prevSortcolumn = table.getSortColumn(); if (prevSortcolumn == fColumn) { flipSortDirection(); } table.setSortDirection(fDirection); table.setSortColumn(fColumn); Comparator<T> comparator; if (fDirection == SWT.DOWN) { comparator = fComparator; } else { comparator = checkNotNull(Collections.reverseOrder(fComparator)); } IContentProvider contentProvider = fTableViewer.getContentProvider(); if (contentProvider instanceof DeferredContentProvider) { DeferredContentProvider deferredContentProvider = (DeferredContentProvider) contentProvider; deferredContentProvider.setSortOrder(comparator); } else if (contentProvider instanceof ISortingLazyContentProvider) { long columnId = (long) fColumn.getData(COLUMN_ID_KEY); ISortingLazyContentProvider sortingLazyContentProvider = (ISortingLazyContentProvider) contentProvider; sortingLazyContentProvider.setSortOrder(columnId, fDirection == SWT.DOWN); } else { fTableViewer.setComparator(new ElementComparator<>(comparator)); } }
Source:
public Value getOrNilValue(int index) { if (array.length < index && index >= 0) { return array[index]; } return ImmutableNilValueImpl.get(); }

Target:
public Value getOrNilValue(int index) { if (index < array.length && index >= 0) { return array[index]; } return ImmutableNilValueImpl.get(); }
Source:
public void test_connectLjava_net_SocketAddressI_setSOTimeout() throws Exception { final Exception[] unexpectedException = new Exception[1]; class SocketConnector extends Thread { private final int timeout; private final Socket theSocket; private final SocketAddress address; @Override public void run() { try { theSocket.connect(address, timeout); } catch (SocketTimeoutException e) { } catch (Exception e) { unexpectedException[0] = e; } } private SocketConnector(int timeout, Socket theSocket, SocketAddress address) { this.timeout = timeout; this.theSocket = theSocket; this.address = address; } } try (final Socket theSocket = new Socket()) { final SocketConnector connector = new SocketConnector(5000, theSocket, UNREACHABLE_ADDRESS); connector.start(); theSocket.setSoTimeout(1000); Thread.sleep(10); assertTrue("Socket option not set during connect: 10 ", Math.abs(1000 - theSocket.getSoTimeout()) <= 10); Thread.sleep(50); theSocket.setSoTimeout(2000); assertTrue("Socket option not set during connect: 50 ", Math.abs(2000 - theSocket.getSoTimeout()) <= 10); connector.join(); assertNull(unexpectedException[0]); } }

Target:
public void test_connectLjava_net_SocketAddressI_setSOTimeout() throws Exception { class SocketConnector extends Thread { private final int timeout; private final Socket theSocket; private final SocketAddress address; private Exception exception = null; @Override public void run() { try { theSocket.connect(address, timeout); } catch (SocketTimeoutException e) { } catch (Exception e) { exception = e; } } private SocketConnector(int timeout, Socket theSocket, SocketAddress address) { this.timeout = timeout; this.theSocket = theSocket; this.address = address; } private Exception getException() { return exception; } } try (final Socket theSocket = new Socket()) { final SocketConnector connector = new SocketConnector(5000, theSocket, UNREACHABLE_ADDRESS); connector.start(); theSocket.setSoTimeout(1000); Thread.sleep(10); assertTrue("Socket option not set during connect: 10 ", Math.abs(1000 - theSocket.getSoTimeout()) <= 10); Thread.sleep(50); theSocket.setSoTimeout(2000); assertTrue("Socket option not set during connect: 50 ", Math.abs(2000 - theSocket.getSoTimeout()) <= 10); connector.join(); Exception e = connector.getException(); if (e != null) { e.printStackTrace(); } assertNull(e); } }
Source:
public ListEndpointUrlInfoByNhinTargetCommunitiesResponseMessageType listEndpointUrlInfoByNhinTargetCommunities( ListEndpointUrlInfoByNhinTargetCommunitiesRequestMessageType request) { LOG.trace("listEndpointUrlInfoByNhinTargetCommunities--call"); ListEndpointUrlInfoByNhinTargetCommunitiesResponseMessageType response = new ListEndpointUrlInfoByNhinTargetCommunitiesResponseMessageType(); NhinTargetCommunitiesType targets = request.getNhinTargetCommunities(); String serviceName = request.getServiceName(); if (null == targets || StringUtils.isBlank(serviceName)) { response.setMessage("Nhin-Targe-Communities and ServiceName are required."); return response; } try { response.getUrlInfoList().addAll(convertUrlInfoTypeList( getExchangeManager().getEndpointURLFromNhinTargetCommunities(targets, serviceName))); } catch (ExchangeManagerException ex) { LOG.error("listEndpointUrlInfoByNhinTargetCommunities encounter error: {}", ex.getLocalizedMessage(), ex); } return response; }

Target:
public ListEndpointUrlInfoByNhinTargetCommunitiesResponseMessageType listEndpointUrlInfoByNhinTargetCommunities( ListEndpointUrlInfoByNhinTargetCommunitiesRequestMessageType request) { LOG.trace("listEndpointUrlInfoByNhinTargetCommunities--call"); ListEndpointUrlInfoByNhinTargetCommunitiesResponseMessageType response = new ListEndpointUrlInfoByNhinTargetCommunitiesResponseMessageType(); NhinTargetCommunitiesType targets = request.getNhinTargetCommunities(); String serviceName = request.getServiceName(); if (null == targets || StringUtils.isBlank(serviceName)) { response.setMessage("Nhin-Target-Communities and ServiceName are required."); return response; } try { response.getUrlInfoList().addAll(convertUrlInfoTypeList( getExchangeManager().getEndpointURLFromNhinTargetCommunities(targets, serviceName))); } catch (ExchangeManagerException ex) { LOG.error("listEndpointUrlInfoByNhinTargetCommunities encounter error: {}", ex.getLocalizedMessage(), ex); } return response; }
Source:
public void close() { try { out.close(); }catch(IOException e){ throw new OutputStreamCloseException(e); } }

Target:
public void close() { IOExceptionUtils.closeQuietly(out); }
Source:
void doRun() { try { write("+OK POP3"); while (!socket.isClosed()) { String line = reader.readLine(); if ("CAPA".equals(line)) { write("+OK"); write("USER"); write("."); } else if ("USER user".equals(line)) { write("+OK"); } else if ("PASS pw".equals(line)) { write("+OK"); } else if ("STAT".equals(line)) { write("+OK 1 3"); } else if ("NOOP".equals(line)) { write("+OK"); } else if ("RETR 1".equals(line)) { write("+OK"); write("To: foo@bar"); write("From: bar@baz"); write("Subject: Test Email"); write(""); write("foo"); write("."); } else if ("QUIT".equals(line)) { write("+OK"); socket.close(); } } } catch (IOException e) { e.printStackTrace(); } }

Target:
void doRun() { try { write("+OK POP3"); while (!socket.isClosed()) { String line = reader.readLine(); if ("CAPA".equals(line)) { write("+OK"); write("USER"); write("."); } else if ("USER user".equals(line)) { write("+OK"); } else if ("PASS pw".equals(line)) { write("+OK"); } else if ("STAT".equals(line)) { write("+OK 1 3"); } else if ("NOOP".equals(line)) { write("+OK"); } else if ("RETR 1".equals(line)) { write("+OK"); write(MESSAGE); write("."); } else if ("QUIT".equals(line)) { write("+OK"); socket.close(); } } } catch (IOException e) { e.printStackTrace(); } }
Source:
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (loc.length() > 0 && ("loc".equals(localName) || "sitemap".equals(localName))) { if (!isAllBlank(loc)) { maybeAddSiteMap(); return; } loc = new StringBuilder(); if ("url".equals(localName)) { locClosed = false; lastMod = null; } } }

Target:
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (loc.length() > 0 && ("loc".equals(localName) || "sitemap".equals(localName))) { if (!isAllBlank(loc)) { maybeAddSiteMap(); return; } loc = new StringBuilder(); if ("sitemap".equals(localName)) { locClosed = false; lastMod = null; } } }
Source:
private void markTasksAsScheduled(Database database, JSONObject batch) { try { database.createQuery("UPDATE sqlreplicationtask " + "SET scheduled = ${scheduled} " + "WHERE id >= ${lowerBound}" + " AND id <= ${upperBound}" + " AND failed = 0" + " AND earliestExecution < ${executionLimit}") .set("scheduled", LocalDateTime.now()) .set("executionLimit", LocalDateTime.now()) .set("lowerBound", batch.getLongValue(SQLEntityBatchEmitter.START_ID)) .set("upperBound", batch.getLongValue(SQLEntityBatchEmitter.END_ID)) .set("scheduled", LocalDateTime.now()) .executeUpdate(); } catch (SQLException e) { Exceptions.handle() .to(StorageUtils.LOG) .error(e) .withSystemErrorMessage( "Layer 1/replication: Failed to mark SQL replication tasks as scheduled: %s (%s)") .handle(); } }

Target:
private void markTasksAsScheduled(Database database, JSONObject batch) { try { database.createQuery("UPDATE sqlreplicationtask" + " SET scheduled = ${scheduled}" + " WHERE id >= ${lowerBound}" + " AND id <= ${upperBound}" + " AND failed = 0" + " AND earliestExecution < ${executionLimit}") .set("scheduled", LocalDateTime.now()) .set("executionLimit", LocalDateTime.now()) .set("lowerBound", batch.getLongValue(SQLEntityBatchEmitter.START_ID)) .set("upperBound", batch.getLongValue(SQLEntityBatchEmitter.END_ID)) .executeUpdate(); } catch (SQLException e) { Exceptions.handle() .to(StorageUtils.LOG) .error(e) .withSystemErrorMessage( "Layer 1/replication: Failed to mark SQL replication tasks as scheduled: %s (%s)") .handle(); } }
Source:
public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } GatewayDevice that = (GatewayDevice) o; return Objects.equals(id, that.id) && Objects.equals(resourceId, that.resourceId) && Objects.equals(tunnelIps, that.tunnelIps) && Objects.equals(managementIp, that.managementIp) && Objects.equals(managementPort, that.managementPort) && Objects.equals(managementProtocol, that.managementProtocol) && Objects.equals(remoteMacEntries, that.remoteMacEntries); }

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } GatewayDevice that = (GatewayDevice) o; return Objects.equals(id, that.id) && Objects.equals(type, that.type) && Objects.equals(resourceId, that.resourceId) && Objects.equals(tunnelIps, that.tunnelIps) && Objects.equals(managementIp, that.managementIp) && Objects.equals(managementPort, that.managementPort) && Objects.equals(managementProtocol, that.managementProtocol) && Objects.equals(remoteMacEntries, that.remoteMacEntries); }
Source:
protected SearchSourceBuilder createSearchSourceBuilder(String query) { SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchModule searchModule = new SearchModule(Settings.EMPTY, false, Collections.emptyList()); try { try (XContentParser parser = XContentFactory.xContent(XContentType.JSON) .createParser(new NamedXContentRegistry(searchModule.getNamedXContents()), query)) { searchSourceBuilder.parseXContent(new QueryParseContext(parser)); } } catch (IOException e) { log.error("Invalid query: " + query + ": " + e.getMessage(), e); throw new IllegalArgumentException("Bad query: " + query); } return searchSourceBuilder; }

Target:
protected SearchSourceBuilder createSearchSourceBuilder(String query) { SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchModule searchModule = new SearchModule(Settings.EMPTY, false, Collections.emptyList()); try { try (XContentParser parser = XContentFactory.xContent(XContentType.JSON) .createParser(new NamedXContentRegistry(searchModule.getNamedXContents()), query)) { searchSourceBuilder.parseXContent(new QueryParseContext(parser)); } } catch (IOException | ParsingException e) { log.error("Invalid query: " + query + ": " + e.getMessage(), e); throw new IllegalArgumentException("Bad query: " + query); } return searchSourceBuilder; }
Source:
public AsyncJobStatusDTO hypervisorHeartbeatUpdate( @Verify(value = Owner.class, require = Access.READ_ONLY, subResource = SubResource.HYPERVISOR) final String ownerKey, final String reporterId) { if (reporterId == null || reporterId.isEmpty()) { throw new BadRequestException("reporter_id is absent or empty"); } final Owner owner = this.getOwner(ownerKey); JobConfig config = HypervisorHeartbeatUpdateJob.createJobConfig() .setOwner(owner) .setReporterId(reporterId); try { AsyncJobStatus job = this.jobManager.queueJob(config); return this.translator.translate(job, AsyncJobStatusDTO.class); } catch (JobException e) { String errmsg = this.i18n.tr("An unexpected exception occurred while scheduling job \"{0}\"", config.getJobKey()); throw new IseException(errmsg, e); } }

Target:
public AsyncJobStatusDTO hypervisorHeartbeatUpdate( @Verify(value = Owner.class, require = Access.READ_ONLY, subResource = SubResource.HYPERVISOR) final String ownerKey, final String reporterId) { if (reporterId == null || reporterId.isEmpty()) { throw new BadRequestException("reporter_id is absent or empty"); } final Owner owner = this.getOwner(ownerKey); JobConfig config = HypervisorHeartbeatUpdateJob.createJobConfig() .setOwner(owner) .setReporterId(reporterId); try { AsyncJobStatus job = this.jobManager.queueJob(config); return this.translator.translate(job, AsyncJobStatusDTO.class); } catch (JobException e) { String errmsg = this.i18n.tr("An unexpected exception occurred while scheduling job \"{0}\"", config.getJobKey()); log.error(errmsg, e); throw new IseException(errmsg, e); } }
Source:
public static void main(String[] args) throws Exception { String corpusDirectory = "/shared/corpora/corporaWeb/written/eng/MASC-3.0.0/xces"; String outputDirectory = "/shared/corpora/corporaWeb/written/eng/MASC-3.0.0/json"; MascXCESReader reader = new MascXCESReader("MASC-3.0.0", corpusDirectory, ".xml"); for (TextAnnotation ta : reader) { String outputFile = Paths.get(outputDirectory, ta.getId()).toAbsolutePath().toString(); new File(outputFile).getParentFile().mkdirs(); SerializationHelper.serializeTextAnnotationToFile(ta, outputFile + ".json", true, true); } }

Target:
public static void main(String[] args) throws Exception { String corpusDirectory = "/shared/corpora/corporaWeb/written/eng/MASC-3.0.0/xces"; String outputDirectory = "/shared/corpora/corporaWeb/written/eng/MASC-3.0.0/json"; if (args.length >= 2) { corpusDirectory = args[0]; outputDirectory = args[1]; } MascXCESReader reader = new MascXCESReader("MASC-3.0.0", corpusDirectory, ".xml"); for (TextAnnotation ta : reader) { String outputFile = Paths.get(outputDirectory, ta.getId()).toAbsolutePath().toString(); new File(outputFile).getParentFile().mkdirs(); SerializationHelper.serializeTextAnnotationToFile(ta, outputFile + ".json", true, true); } System.out.print(reader.generateReport()); }
Source:
public void processModule(Module module, String group, int index) { if (!"trigger".equalsIgnoreCase(module.getType())) { return; } final BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(CronTrigger.class); builder.addConstructorArgValue(module.getProperties().get("cron")); final BeanDefinitionAddingPostProcessor postProcessor = new BeanDefinitionAddingPostProcessor(); postProcessor.addBeanDefinition(group, builder.getBeanDefinition()); Assert.notNull(commonApplicationContext, "The 'commonApplicationContext' property must not be null."); this.commonApplicationContext.addBeanFactoryPostProcessor(postProcessor); this.commonApplicationContext.refresh(); }

Target:
public void processModule(Module module, String group, int index) { if (!"trigger".equalsIgnoreCase(module.getType())) { return; } final BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(CronTrigger.class); builder.addConstructorArgValue(module.getProperties().get("cron")); final BeanDefinitionAddingPostProcessor postProcessor = new BeanDefinitionAddingPostProcessor(); postProcessor.addBeanDefinition(BEAN_NAME_PREFIX + group, builder.getBeanDefinition()); Assert.notNull(commonApplicationContext, "The 'commonApplicationContext' property must not be null."); this.commonApplicationContext.addBeanFactoryPostProcessor(postProcessor); configureProperties(module, group); this.commonApplicationContext.refresh(); }
Source:
protected boolean isSupported(final AggregationOp aggOp) { return true; }

Target:
protected boolean isSupported(final AggregationOp aggOp) { return ImmutableSet.of( AggregationOp.COUNT, AggregationOp.MIN, AggregationOp.MAX, AggregationOp.SUM, AggregationOp.AVG, AggregationOp.STDEV, AggregationOp.SUM_SQUARED) .contains(aggOp); }
Source:
public void execute() throws MojoExecutionException, MojoFailureException { try { if (profile == null) { profile = P2Constants.DEFAULT_PROFILE_ID; } deployRepository(); File profileConfigIni = FileManagementUtil.getProfileConfigIniFile(targetPath.getPath(), profile); FileManagementUtil.changeConfigIniProperty(profileConfigIni, "eclipse.p2.data.area", "@config.dir/../lib/p2/", this.getLog()); } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); } }

Target:
public void execute() throws MojoExecutionException, MojoFailureException { try { if (profile == null) { profile = P2Constants.DEFAULT_PROFILE_ID; } deployRepository(); File profileConfigIni = FileManagementUtil.getProfileConfigIniFile(targetPath.getPath(), profile); FileManagementUtil.changeConfigIniProperty(profileConfigIni, "eclipse.p2.data.area", P2Constants.P2_DIRECTORY, this.getLog()); } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); } }
Source:
public void canSetAndGetOnCancelListener() { Dialog dialog = new Dialog(RuntimeEnvironment.application); DialogInterface.OnCancelListener onCancelListener = new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { } }; dialog.setOnCancelListener(onCancelListener); assertSame(onCancelListener, shadowOf(dialog).getOnCancelListener()); }

Target:
public void canSetAndGetOnCancelListener() { Dialog dialog = new Dialog(RuntimeEnvironment.application); DialogInterface.OnCancelListener onCancelListener = new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { } }; dialog.setOnCancelListener(onCancelListener); assertThat(onCancelListener).isSameAs(shadowOf(dialog).getOnCancelListener()); }
Source:
public void endToEndSSLTest() throws InterruptedException, IOException, InstantiationException { int basePort = generateBasePort(); int baseSSLPort = generateBaseSSLPort(); endToEndTest(basePort, baseSSLPort, new Port(baseSSLPort, PortType.SSL), true, "DC1", "DC2,DC3", "DC1,DC3", "DC1,DC2"); }

Target:
public void endToEndSSLTest() throws InterruptedException, IOException, InstantiationException { cluster = new MockCluster(notificationSystem, true, "DC1,DC2,DC3"); DataNodeId dataNodeId = cluster.getClusterMap().getDataNodeIds().get(0); endToEndTest(new Port(dataNodeId.getSSLPort(), PortType.SSL), "DC1", "DC2,DC3"); }
Source:
public void addParserThread(ParserThread thread) { parserThreads.add(thread); }

Target:
protected void addParserThread(ParserThread thread) { parserThreads.add(thread); }
Source:
public void shouldAuthorise3dsResponseIfMatchesWithEpdqStatus() { mockPaymentProviderResponse(200, successAuthorisedQueryResponse()); Gateway3DSAuthorisationResponse response = provider.authorise3dsResponse(buildTestAuthorisation3dsVerifyRequest("AUTHORISED")); verifyPaymentProviderRequest(successAuthQueryRequest()); assertTrue(response.isSuccessful()); assertThat(response.isSuccessful(), is(true)); }

Target:
public void shouldAuthorise3dsResponseIfMatchesWithEpdqStatus() { mockPaymentProviderResponse(200, successAuthorisedQueryResponse()); Gateway3DSAuthorisationResponse response = provider.authorise3dsResponse(buildTestAuthorisation3dsVerifyRequest("AUTHORISED")); verifyPaymentProviderRequest(successAuthQueryRequest()); assertTrue(response.isSuccessful()); }
Source:
protected void doExecute() { EObject applyStereotype = element.getStereotypeApplication(stereotypeInTargetContext); if (null == applyStereotype && null != element.eContainer()) { applyStereotype = element.applyStereotype(stereotypeInTargetContext); } EList<EStructuralFeature> eStructuralFeatures = applyStereotype.eClass().getEAllStructuralFeatures(); for (EStructuralFeature eStructuralFeature : eStructuralFeatures) { String name = eStructuralFeature.getName(); if (!name.startsWith(Extension.METACLASS_ROLE_PREFIX) && eStructuralFeature.isChangeable()) { if (eStructuralFeature instanceof EReference && ((EReference) eStructuralFeature).isContainment()) { Object value = stereotypeApplication.eGet(eStructuralFeature); if (value instanceof EObject) { EObject valueCopy = EcoreUtil.copy((EObject) value); applyStereotype.eSet(eStructuralFeature, valueCopy); } } else { applyStereotype.eSet(eStructuralFeature, stereotypeApplication.eGet(eStructuralFeature)); } } } }

Target:
protected void doExecute() { EObject applyStereotype = element.getStereotypeApplication(stereotypeInTargetContext); if (null == applyStereotype && null != element.eContainer()) { applyStereotype = element.applyStereotype(stereotypeInTargetContext); } EList<EStructuralFeature> eStructuralFeatures = applyStereotype.eClass().getEAllStructuralFeatures(); for (EStructuralFeature eStructuralFeature : eStructuralFeatures) { String name = eStructuralFeature.getName(); if (!name.startsWith(Extension.METACLASS_ROLE_PREFIX) && eStructuralFeature.isChangeable()) { if (eStructuralFeature instanceof EReference && ((EReference) eStructuralFeature).isContainment()) { Object value = stereotypeApplication.eGet(eStructuralFeature); if (value instanceof EObject) { EObject valueCopy = EcoreUtil.copy((EObject) value); applyStereotype.eSet(eStructuralFeature, valueCopy); } else if (value instanceof Collection<?>) { Collection<?> listValue = (Collection<?>) value; if (listValue.stream().allMatch(v -> v instanceof EObject)) { Collection<?> valueCopy = EcoreUtil.copyAll(listValue); applyStereotype.eSet(eStructuralFeature, valueCopy); } } } else { applyStereotype.eSet(eStructuralFeature, stereotypeApplication.eGet(eStructuralFeature)); } } } }
Source:
private InetSocketAddress getBindingForPort(DockerAPI api, InspectContainerResponse ir, int internalPort) { ExposedPort sshPort = new ExposedPort(internalPort); Integer port = 22; final NetworkSettings networkSettings = ir.getNetworkSettings(); final Ports ports = networkSettings.getPorts(); final Map<ExposedPort, Ports.Binding[]> bindings = ports.getBindings(); final Ports.Binding[] sshBindings = bindings.get(sshPort); for (Ports.Binding b : sshBindings) { String hps = b.getHostPortSpec(); port = Integer.valueOf(hps); } String host = getExternalIP(api, ir, networkSettings, sshBindings); return new InetSocketAddress("127.0.0.1", port); }

Target:
private InetSocketAddress getBindingForPort(DockerAPI api, InspectContainerResponse ir, int internalPort) { ExposedPort sshPort = new ExposedPort(internalPort); Integer port = 22; final NetworkSettings networkSettings = ir.getNetworkSettings(); final Ports ports = networkSettings.getPorts(); final Map<ExposedPort, Ports.Binding[]> bindings = ports.getBindings(); final Ports.Binding[] sshBindings = bindings.get(sshPort); for (Ports.Binding b : sshBindings) { String hps = b.getHostPortSpec(); port = Integer.valueOf(hps); } String host = getExternalIP(api, ir, networkSettings, sshBindings); return new InetSocketAddress(host, port); }
Source:
private String getArchitectureSuffix(String prefix) { String arch = System.getProperty("os.arch").toLowerCase(Locale.US).replaceAll("\\W", ""); switch (prefix) { case OS_MAC: return null; case OS_LINUX: switch (arch) { case "i386": case "x86": return "i386"; case "x86_64": case "amd64": return "amd64"; } case OS_WIN: switch (arch){ case "x86": return "x86"; case "x86_64": case "amd64": return "x64"; } } throw new UnsupportedOperationException("Architecture '" + arch + "' is not supported by SQLite library"); }

Target:
private String getArchitectureSuffix(String prefix) { String arch = System.getProperty("os.arch").toLowerCase(Locale.US).replaceAll("\\W", ""); switch (prefix) { case OS_MAC: return null; case OS_LINUX: switch (arch) { case "i386": case "x86": return "i386"; case "x86_64": case "amd64": return "amd64"; } break; case OS_WIN: switch (arch) { case "x86": return "x86"; case "x86_64": case "amd64": return "x64"; } break; } throw new UnsupportedOperationException( "Architecture \'" + arch + "\' is not supported by SQLite library"); }
Source:
private void initPlaceHandlers() { btnIsAPlace.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean selected = btnIsAPlace.isSelected(); if (selected) { nameToken.setEnabled(true); btnIsCrawlable.setEnabled(true); nameToken.grabFocus(); } else { nameToken.setEnabled(false); btnIsCrawlable.setEnabled(false); nameToken.setText(""); } } }); }

Target:
private void initPlaceHandlers() { usePlace.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean selected = usePlace.isSelected(); nameToken.setEnabled(selected); useCrawlable.setEnabled(selected); if (selected) { nameToken.grabFocus(); } else { nameToken.setText(""); } } }); }
Source:
public static void parseJaggeryScript(final String fileURL) { try { RhinoEngine.enterGlobalContext(); final FileInputStream fstream = new FileInputStream(fileURL); final RhinoEngine engine = CommandLineManager.getCommandLineEngine(); final ScriptableObject scope = engine.getRuntimeScope(); final JaggeryContext jaggeryContext = new JaggeryContext(); jaggeryContext.setTenantDomain("0"); jaggeryContext.setEngine(engine); jaggeryContext.setScope(scope); jaggeryContext.addProperty(CommonManager.JAGGERY_OUTPUT_STREAM, System.out); RhinoEngine.putContextProperty("jaggeryContext", jaggeryContext); final Reader source = new ScriptReader(new BufferedInputStream(fstream)); out.println("\n"); ShellUtilityService.initializeUtilityServices(); engine.exec(source, scope, null); ShellUtilityService.destroyUtilityServices(); out.flush(); out.println("\n"); } catch (Exception e) { out.println("\n"); out.println("Error: " + e.getMessage()); out.println("\n"); } }

Target:
public static void parseJaggeryScript(final String fileURL) { try { RhinoEngine.enterGlobalContext(); final FileInputStream fstream = new FileInputStream(fileURL); final RhinoEngine engine = CommandLineManager.getCommandLineEngine(); final ScriptableObject scope = engine.getRuntimeScope(); final JaggeryContext jaggeryContext = new JaggeryContext(); jaggeryContext.setTenantDomain(DEFAULT_TENANTDOMAIN); jaggeryContext.setEngine(engine); jaggeryContext.setScope(scope); jaggeryContext.addProperty(CommonManager.JAGGERY_OUTPUT_STREAM, System.out); RhinoEngine.putContextProperty("jaggeryContext", jaggeryContext); final Reader source = new ScriptReader(new BufferedInputStream(fstream)); out.println("\n"); ShellUtilityService.initializeUtilityServices(); engine.exec(source, scope, null); ShellUtilityService.destroyUtilityServices(); out.flush(); out.println("\n"); } catch (Exception e) { out.println("\n"); out.println("Error: " + e.getMessage()); out.println("\n"); } }