Project

General

Profile

« Previous | Next » 

Revision 42815

patch for fixing issue #2121

View differences:

modules/dnet-download-service/trunk/src/main/java/eu/dnetlib/data/download/rmi/DownloadServiceFeeder.java
32 32

  
33 33
	/** The Constant log. */
34 34
	private static final Log log = LogFactory.getLog(DownloadServiceFeeder.class);
35
	private static final int MAX_NUM_FOUND = 10;
35 36

  
36 37
	/** The download plugin enumerator. */
37 38
	@Resource
......
45 46
	@Autowired
46 47
	private ObjectStoreDao objectStoreDao;
47 48

  
49
	public static void reportException(final DownloadReportMap report, final DownloadItem di, final Throwable e) {
50
		final String className = e.getClass().getName();
51
		if (!report.containsKey(className)) {
52
			final DownloadReport dr = new DownloadReport();
53
			dr.setStackTrace(Joiner.on("\tat ").join(e.getStackTrace()));
54
			if (di != null) {
55
				dr.setDownloadItem(di);
56
			}
57
			report.put(className, dr);
58
		} else {
59
			report.get(className).incrementError();
60
		}
61
	}
62

  
48 63
	/**
49 64
	 * Download and feed file into the objectStore .
50 65
	 *
......
124 139
		}
125 140

  
126 141
		int i = 0;
142
		int null_found = 0;
127 143
		if (urlInfo != null) {
128 144
			for (final String downloadItem : urlInfo) {
129 145
				if (downloadItem != null) {
146
					null_found = 0;
130 147
					if ((i++ % 1000) == 0) {
131 148
						log.debug("Read " + i);
132 149
					}
......
135 152
					} catch (final Exception e) {
136 153
						log.error("An error occurred while populating the download items queue: " + Joiner.on("\tat ").join(e.getStackTrace()));
137 154
					}
155
				} else {
156
					if (null_found++ > MAX_NUM_FOUND) {
157
						break;
158
					}
138 159
				}
160

  
139 161
			}
140 162
		}
141 163

  
......
150 172
		return resultMap;
151 173
	}
152 174

  
153
	private void reportException(final DownloadReportMap report, final DownloadItem di, final Throwable e) {
154
		final String className = e.getClass().getName();
155
		if (!report.containsKey(className)) {
156
			final DownloadReport dr = new DownloadReport();
157
			dr.setStackTrace(Joiner.on("\tat ").join(e.getStackTrace()));
158
			if (di != null) {
159
				dr.setDownloadItem(di);
160
			}
161
			report.put(className, dr);
162
		} else {
163
			report.get(className).incrementError();
164
		}
165
	}
166

  
167 175
	private DownloadReportMap getDownloadReportMap(final List<Future<DownloadReportMap>> responses, final DownloadReportMap pluginReport) {
168 176
		final DownloadReportMap resultMap = new DownloadReportMap();
169 177
		resultMap.setStatus(true);

Also available in: Unified diff