|
1 | 1 | /*
|
2 |
| - * Copyright 2014-2019 MarkLogic Corporation |
| 2 | + * Copyright 2014-2020 MarkLogic Corporation |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -246,14 +246,22 @@ private void replenishStream() throws Exception {
|
246 | 246 | // the callback receives the output stream
|
247 | 247 | public void write(OutputStream out) throws IOException {
|
248 | 248 | // acquire the content
|
249 |
| - InputStream docStreamwrongjson = new FileInputStream( |
250 |
| - WriteHostBatcherTest.class.getResource(TEST_DIR_PREFIX + "WrongFormat.json").getPath()); |
| 249 | + InputStream docStreamwrongjson = null; |
| 250 | + try { |
| 251 | + docStreamwrongjson = new FileInputStream( |
| 252 | + WriteHostBatcherTest.class.getResource(TEST_DIR_PREFIX + "WrongFormat.json").getPath()); |
251 | 253 |
|
252 |
| - // copy content to the output stream |
253 |
| - byte[] buf = new byte[1024]; |
254 |
| - int byteCount = 0; |
255 |
| - while ((byteCount = docStreamwrongjson.read(buf)) != -1) { |
256 |
| - out.write(buf, 0, byteCount); |
| 254 | + // copy content to the output stream |
| 255 | + byte[] buf = new byte[1024]; |
| 256 | + int byteCount = 0; |
| 257 | + while ((byteCount = docStreamwrongjson.read(buf)) != -1) { |
| 258 | + out.write(buf, 0, byteCount); |
| 259 | + } |
| 260 | + } catch (Exception e) { |
| 261 | + e.printStackTrace(); |
| 262 | + } |
| 263 | + finally { |
| 264 | + docStreamwrongjson.close(); |
257 | 265 | }
|
258 | 266 |
|
259 | 267 | }
|
@@ -1434,7 +1442,7 @@ public void run() {
|
1434 | 1442 | // TODO Auto-generated catch block
|
1435 | 1443 | e.printStackTrace();
|
1436 | 1444 | }
|
1437 |
| - Set threads = Thread.getAllStackTraces().keySet(); |
| 1445 | + Set<Thread> threads = Thread.getAllStackTraces().keySet(); |
1438 | 1446 | Iterator<Thread> iter = threads.iterator();
|
1439 | 1447 | while (iter.hasNext()) {
|
1440 | 1448 | Thread t = iter.next();
|
@@ -1519,7 +1527,7 @@ public void run() {
|
1519 | 1527 | // TODO Auto-generated catch block
|
1520 | 1528 | e.printStackTrace();
|
1521 | 1529 | }
|
1522 |
| - Set threads = Thread.getAllStackTraces().keySet(); |
| 1530 | + Set<Thread> threads = Thread.getAllStackTraces().keySet(); |
1523 | 1531 | Iterator<Thread> iter = threads.iterator();
|
1524 | 1532 | while (iter.hasNext()) {
|
1525 | 1533 | Thread t = iter.next();
|
@@ -1611,7 +1619,7 @@ public void run() {
|
1611 | 1619 | // TODO Auto-generated catch block
|
1612 | 1620 | e.printStackTrace();
|
1613 | 1621 | }
|
1614 |
| - Set threads = Thread.getAllStackTraces().keySet(); |
| 1622 | + Set<Thread> threads = Thread.getAllStackTraces().keySet(); |
1615 | 1623 | Iterator<Thread> iter = threads.iterator();
|
1616 | 1624 | while (iter.hasNext()) {
|
1617 | 1625 | Thread t = iter.next();
|
@@ -1762,7 +1770,7 @@ public void run() {
|
1762 | 1770 | }
|
1763 | 1771 | Iterator<Entry<String, Integer>> it = threadMap.entrySet().iterator();
|
1764 | 1772 | while (it.hasNext()) {
|
1765 |
| - Map.Entry<String, Integer> pair = (Map.Entry) it.next(); |
| 1773 | + Map.Entry<String, Integer> pair = (Entry<String, Integer>) it.next(); |
1766 | 1774 | System.out.println("Thread pool: " + pair.getKey() + " = " + pair.getValue() + " Threads");
|
1767 | 1775 | if (pair.getValue() == 20) {
|
1768 | 1776 | count.set(true);
|
@@ -1823,6 +1831,7 @@ public void testNPESuccessCallBack() throws Exception {
|
1823 | 1831 | System.out.println("Job writes " + batch.getJobWritesSoFar());
|
1824 | 1832 | successCount.getAndAdd(batch.getItems().length);
|
1825 | 1833 | String s = null;
|
| 1834 | + // s.length is called purposefully to set off NEE. |
1826 | 1835 | s.length();
|
1827 | 1836 |
|
1828 | 1837 | }).onBatchFailure((batch, throwable) -> {
|
@@ -2364,8 +2373,6 @@ public void testNullConfig() throws Exception {
|
2364 | 2373 |
|
2365 | 2374 | final String query1 = "fn:count(fn:doc())";
|
2366 | 2375 |
|
2367 |
| - DocumentMetadataHandle meta6 = new DocumentMetadataHandle().withCollections("NoHost").withQuality(0); |
2368 |
| - |
2369 | 2376 | Assert.assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 0);
|
2370 | 2377 |
|
2371 | 2378 | WriteBatcher ihb2 = dmManager.newWriteBatcher();
|
@@ -2910,7 +2917,7 @@ public void testDocumentWriteOperationAdd() throws Exception {
|
2910 | 2917 |
|
2911 | 2918 | metadataHandle.setQuality(23);
|
2912 | 2919 | DocumentWriteOperationImpl docWriteOpsImp4 = new DocumentWriteOperationImpl(
|
2913 |
| - OperationType.DISABLE_METADATA_DEFAULT, |
| 2920 | + OperationType.DOCUMENT_WRITE, |
2914 | 2921 | docId[4],
|
2915 | 2922 | metadataHandle,
|
2916 | 2923 | contHandle5
|
|
0 commit comments