Skip to content

Some code that can be simplified #18342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public JSONArray() {
public JSONArray(Collection copyFrom) {
this();
if (copyFrom != null) {
for (Iterator it = copyFrom.iterator(); it.hasNext();) {
put(JSONObject.wrap(it.next()));
for (Object it : copyFrom) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When merging, I think we should leave this as-is so that it matches the original source.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thank you for your letter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it matches the original source

@wilkinsona I'm sorry but I don't quite understand, what's the difference of these two versions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no functional difference, but the source code is different. This code is a copy of code authored elsewhere and we don't want to diverge from its original form.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks for clarification! :)

put(JSONObject.wrap(it));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ boolean isZip(File file) {
}

private boolean isZip(InputStream inputStream) throws IOException {
for (int i = 0; i < ZIP_FILE_HEADER.length; i++) {
if (inputStream.read() != ZIP_FILE_HEADER[i]) {
for (byte b : ZIP_FILE_HEADER) {
if (inputStream.read() != b) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,14 +544,7 @@ protected TomcatWebServer getTomcatWebServer(Tomcat tomcat) {
@Test
void registerJspServletWithDefaultLoadOnStartup() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
factory.addInitializers(new ServletContextInitializer() {

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.addServlet("manually-registered-jsp-servlet", JspServlet.class);
}

});
factory.addInitializers(servletContext -> servletContext.addServlet("manually-registered-jsp-servlet", JspServlet.class));
this.webServer = factory.getWebServer();
this.webServer.start();
}
Expand Down