Project

General

Profile

« Previous | Next » 

Revision a2fb3579

Added by Andreas Kohlbecker over 2 years ago

ref #3811 resoring lost code line and solving "Null pointer access" problem

View differences:

cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/service/DataController.java
8 8
*/
9 9
package eu.etaxonomy.cdm.remote.service;
10 10

  
11
import io.swagger.annotations.Api;
12

  
13 11
import java.io.IOException;
14 12
import java.io.InputStream;
15 13
import java.io.OutputStream;
......
31 29
import eu.etaxonomy.cdm.api.service.lsid.LSIDDataService;
32 30
import eu.etaxonomy.cdm.model.common.LSID;
33 31
import eu.etaxonomy.cdm.remote.editor.LSIDPropertyEditor;
32
import io.swagger.annotations.Api;
34 33

  
35 34
/**
36 35
 * Controller which accepts requests for the data representation of an object
......
75 74
                                @RequestParam("start") Integer start,
76 75
                                @RequestParam("length") Integer length,
77 76
                                HttpServletResponse response) throws LSIDServerException, IOException  {
78
        //FIXME #3811 fix null pointer access of "out" reference
79
//		OutputStream out = null;
80
//		InputStream data = null;
81
//		try {
82
//			data = lsidDataService.getDataByRange(lsid,start,length);
83
//		    if(data != null) {
84
//		    	response.setContentType("application/octet-stream");
85
//		    	byte[] bytes = new byte[1024];
86
//		    	int numbytes = data.read(bytes);
87
//		    	while (numbytes != -1) {
88
//		    		out.write(bytes,0,numbytes);
89
//		    		numbytes = data.read(bytes);
90
//		    	}
91
//		    	out.flush();
92
//		    }
93
//		} finally {
94
//			if (out != null) {
95
//				out.close();
96
//			}
97
//
98
//			if (data != null) {
99
//				data.close();
100
//			}
101
//		}
77

  
78
		OutputStream out = null;
79
		InputStream data = null;
80
		try {
81
			data = lsidDataService.getDataByRange(lsid,start,length);
82
		    if(data != null) {
83
		    	response.setContentType("application/octet-stream");
84
		    	out = response.getOutputStream();
85
		    	byte[] bytes = new byte[1024];
86
		    	int numbytes = data.read(bytes);
87
		    	while (numbytes != -1) {
88
		    		out.write(bytes,0,numbytes);
89
		    		numbytes = data.read(bytes);
90
		    	}
91
		    	out.flush();
92
		    }
93
		} finally {
94
			if (out != null) {
95
				out.close();
96
			}
97

  
98
			if (data != null) {
99
				data.close();
100
			}
101
		}
102 102
        return null;
103 103
    }
104 104

  

Also available in: Unified diff