Skip to content
Permalink
Browse files

[22-printjob-sideeffect]: Remove PrintJob.getProperties side effect

  • Loading branch information
sanmibuh committed Aug 26, 2019
1 parent e6e0fac commit 58a6557aca99b8c2942c899f730d7cd83aabb993
@@ -4,3 +4,4 @@
/pom-2018-01-24.xml
cups4j.iml
/deploy.txt
.idea
@@ -95,9 +95,6 @@ public PrintRequestResult print(PrintJob printJob) throws Exception {
if (userName == null) {
userName = CupsClient.DEFAULT_USER;
}
if (attributes == null) {
attributes = new HashMap<String, String>();
}

attributes.put("requesting-user-name", userName);
attributes.put("job-name", jobName);
@@ -16,6 +16,7 @@
*/
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

public class PrintJob {
@@ -230,7 +231,7 @@ public PrintJob build() {
}

public Map<String, String> getAttributes() {
return attributes;
return attributes == null ? new HashMap<String, String>() : new HashMap<String, String>(attributes);
}

public InputStream getDocument() {
@@ -82,9 +82,6 @@ public IppResult request(URL printerURL, PrintJob printJob) {
if (userName == null) {
userName = CupsClient.DEFAULT_USER;
}
if (attributes == null) {
attributes = new HashMap<String, String>();
}

attributes.put("requesting-user-name", userName);
attributes.put("job-name", jobName);

0 comments on commit 58a6557

Please sign in to comment.
You can’t perform that action at this time.