diff --git a/src/main/java/com/marklogic/contentpump/DatabaseContentReader.java b/src/main/java/com/marklogic/contentpump/DatabaseContentReader.java index 98efb7da6..ca5fed8f9 100644 --- a/src/main/java/com/marklogic/contentpump/DatabaseContentReader.java +++ b/src/main/java/com/marklogic/contentpump/DatabaseContentReader.java @@ -499,6 +499,9 @@ private String parseMetadata(DocumentMetadata metadata) throws IOException { metadata.setPermString(buf.toString()); // handle quality, always present even if not requested (barrier) + if (item == null) { + throw new IOException("Unexpected null item when reading quality"); + } metadata.setQuality((XSInteger) item.getItem()); // handle metadata @@ -625,7 +628,7 @@ public boolean nextKeyValue() throws IOException, InterruptedException { queryNakedProperties(); int curCount = 0; while (curCount < nakedCount) { - if (result.hasNext()) { + if (result != null && result.hasNext()) { result.next(); curCount++; } else { @@ -634,7 +637,7 @@ public boolean nextKeyValue() throws IOException, InterruptedException { } } - if (result.hasNext()) { + if (result != null && result.hasNext()) { ResultItem currItem = null; currItem = result.next(); diff --git a/src/main/java/com/marklogic/contentpump/OutputArchive.java b/src/main/java/com/marklogic/contentpump/OutputArchive.java index 526503403..16251209d 100644 --- a/src/main/java/com/marklogic/contentpump/OutputArchive.java +++ b/src/main/java/com/marklogic/contentpump/OutputArchive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2020 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved. + * Copyright (c) 2011-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -133,8 +133,9 @@ public void write(String uri, InputStream is, long size, boolean isExportDoc) throws IOException { ZipEntry entry = new ZipEntry(uri); - if (outputStream == null || - (currentFileBytes + size > Integer.MAX_VALUE) && + if (outputStream == null) { + newOutputStream(); + } else if ((currentFileBytes + size > Integer.MAX_VALUE) && currentFileBytes > 0) { if (currentEntries % 2 == 0 && !isExportDoc) { //the file overflowed is metadata, create new zip diff --git a/src/main/java/com/marklogic/mapreduce/DatabaseDocument.java b/src/main/java/com/marklogic/mapreduce/DatabaseDocument.java index 41c711865..a165b7fb9 100644 --- a/src/main/java/com/marklogic/mapreduce/DatabaseDocument.java +++ b/src/main/java/com/marklogic/mapreduce/DatabaseDocument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2021 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved. + * Copyright (c) 2011-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,13 +75,17 @@ public Text getContentAsText() { */ public byte[] getContentAsByteArray() { if (content == null) { - try { - content = IOHelper.byteArrayFromStream(is); - } catch (IOException e) { - throw new RuntimeException("IOException buffering binary data", - e); + if (is != null) { + try { + content = IOHelper.byteArrayFromStream(is); + } catch (IOException e) { + throw new RuntimeException("IOException buffering binary data", + e); + } + is = null; + } else { + content = new byte[0]; } - is = null; } return content; } diff --git a/src/main/java/com/marklogic/mapreduce/MarkLogicInputFormat.java b/src/main/java/com/marklogic/mapreduce/MarkLogicInputFormat.java index 0853c4c35..31cb657b0 100644 --- a/src/main/java/com/marklogic/mapreduce/MarkLogicInputFormat.java +++ b/src/main/java/com/marklogic/mapreduce/MarkLogicInputFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2021 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved. + * Copyright (c) 2011-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -223,7 +223,9 @@ protected void getForestSplits(JobContext jobContext, throw new IOException("Unexpected item " + item.getItemType().toString()); } String itemStr = ((XSString)item.getItem()).asString(); - ruleUris.add(itemStr); + if (ruleUris != null) { + ruleUris.add(itemStr); + } } // forest with failover hosts diff --git a/src/main/java/com/marklogic/mapreduce/utilities/InternalUtilities.java b/src/main/java/com/marklogic/mapreduce/utilities/InternalUtilities.java index 85ed40372..44aab4cf6 100644 --- a/src/main/java/com/marklogic/mapreduce/utilities/InternalUtilities.java +++ b/src/main/java/com/marklogic/mapreduce/utilities/InternalUtilities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved. + * Copyright (c) 2011-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -365,6 +365,7 @@ static ContentSource getSecureContentSource(String host, int port, try { options = new SecurityOptions(sslOptions.getSslContext()); } catch (KeyManagementException | NoSuchAlgorithmException e) { + LOG.error("Error constructing SecurityOptions", e); throw new XccConfigException("Error constructing SecurityOptions", e); }