ASF Bugzilla – Attachment 31192 Details for
Bug 55976
Broken response from NIO connector in Tomcat 7.0.50
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Alternative Test Case - Java class
TomcatNioTest.java (text/plain), 1.60 KB, created by
Konstantin Preißer
on 2014-01-09 17:07:32 UTC
(
hide
)
Description:
Alternative Test Case - Java class
Filename:
MIME Type:
Creator:
Konstantin Preißer
Created:
2014-01-09 17:07:32 UTC
Size:
1.60 KB
patch
obsolete
>package test; > >import java.io.IOException; >import java.io.InputStream; >import java.net.HttpURLConnection; >import java.net.URL; > >public class TomcatNioTest { > > public static void main(String[] args) { > > new TomcatNioTest().startTest("http://localhost:8080/testnio/files/"); > > } > > > private byte[] tempBuffer = new byte[32768]; > > private void readUrl(URL u, long expectedSize) throws IOException { > HttpURLConnection con = (HttpURLConnection) u.openConnection(); > > long byteCount = 0; > try (InputStream in = con.getInputStream()) { > int read; > while ((read = in.read(tempBuffer)) > 0) { > byteCount += read; > } > } > > if (byteCount != expectedSize) { > throw new RuntimeException("Size mismatch for URL " + u.toString() + " - Expected: " + expectedSize + ", Got: " + byteCount); > } > } > > > private void startTest(final String urlPrefix) { > System.out.println("Start..."); > > // Start 100 threads, each of them requesting 100 URLs. > Thread[] threads = new Thread[100]; > for (int j = 0; j < 100; j++) { > threads[j] = new Thread(new Runnable() { > @Override > public void run() { > // Read 100 URLs > try { > for (int i = 0; i < 100; i++) { > readUrl(new URL(urlPrefix + "TextFile" + i + ".txt"), 58003); > } > } catch (IOException ex) { > ex.printStackTrace(); > } > } > }); > threads[j].start(); > } > > // Join all threads > try { > for (int j = 0; j < 100; j++) { > threads[j].join(); > } > } catch (InterruptedException e) { > e.printStackTrace(); > } > > System.out.println("Finished."); > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 55976
:
31182
|
31183
|
31184
|
31185
|
31190
|
31191
| 31192