• R/O
  • SSH
  • HTTPS

nicoro: Commit


Commit MetaInfo

Revisão572 (tree)
Hora2013-01-14 16:52:47
Autorshisei123

Mensagem de Log

クラッシュ修正&クラッシュ解析一時コード組み込み

Mudança Sumário

Diff

--- trunk/NicoRo/src/jp/sourceforge/nicoro/RelatedVideoLoader.java (revision 571)
+++ trunk/NicoRo/src/jp/sourceforge/nicoro/RelatedVideoLoader.java (revision 572)
@@ -211,29 +211,37 @@
211211 mDataCount = Integer.parseInt(text);
212212 videos.ensureCapacity(mDataCount);
213213 } else if ("url".equals(name)) {
214- assert video != null;
215- video.url = text;
214+ if (video != null) {
215+ video.url = text;
216+ }
216217 } else if ("thumbnail".equals(name)) {
217- assert video != null;
218- video.thumbnail = text;
218+ if (video != null) {
219+ video.thumbnail = text;
220+ }
219221 } else if ("title".equals(name)) {
220- assert video != null;
221- video.title = text;
222+ if (video != null) {
223+ video.title = text;
224+ }
222225 } else if ("view".equals(name)) {
223- assert video != null;
224- video.view = Integer.parseInt(text);
226+ if (video != null) {
227+ video.view = Integer.parseInt(text);
228+ }
225229 } else if ("comment".equals(name)) {
226- assert video != null;
227- video.comment = Integer.parseInt(text);
230+ if (video != null) {
231+ video.comment = Integer.parseInt(text);
232+ }
228233 } else if ("mylist".equals(name)) {
229- assert video != null;
230- video.mylist = Integer.parseInt(text);
234+ if (video != null) {
235+ video.mylist = Integer.parseInt(text);
236+ }
231237 } else if ("length".equals(name)) {
232- assert video != null;
233- video.length = Integer.parseInt(text);
238+ if (video != null) {
239+ video.length = Integer.parseInt(text);
240+ }
234241 } else if ("time".equals(name)) {
235- assert video != null;
236- video.time = Long.parseLong(text);
242+ if (video != null) {
243+ video.time = Long.parseLong(text);
244+ }
237245 } else {
238246 // その他のタグはとりあえず無視
239247 }
@@ -251,23 +259,24 @@
251259 .append(">").toString());
252260 }
253261 if ("video".equals(name)) {
254- assert video != null;
255- videos.add(video);
262+ if (video != null) {
263+ videos.add(video);
256264
257- if (DEBUG_LOGD) {
258- Log.d(LOG_TAG, Log.buf().append("video:")
259- .append(" url=").append(video.url)
260- .append(" thumbnail=").append(video.thumbnail)
261- .append(" title=").append(video.title)
262- .append(" view=").append(video.view)
263- .append(" comment=").append(video.comment)
264- .append(" mylist=").append(video.mylist)
265- .append(" length=").append(video.length)
266- .append(" time=").append(video.time)
267- .toString());
268- }
265+ if (DEBUG_LOGD) {
266+ Log.d(LOG_TAG, Log.buf().append("video:")
267+ .append(" url=").append(video.url)
268+ .append(" thumbnail=").append(video.thumbnail)
269+ .append(" title=").append(video.title)
270+ .append(" view=").append(video.view)
271+ .append(" comment=").append(video.comment)
272+ .append(" mylist=").append(video.mylist)
273+ .append(" length=").append(video.length)
274+ .append(" time=").append(video.time)
275+ .toString());
276+ }
269277
270- video = null;
278+ video = null;
279+ }
271280 } else {
272281 // その他のタグはとりあえず無視
273282 }
--- trunk/NicoRo/src/jp/sourceforge/nicoro/MultiRandomAccessFile.java (revision 571)
+++ trunk/NicoRo/src/jp/sourceforge/nicoro/MultiRandomAccessFile.java (revision 572)
@@ -215,58 +215,69 @@
215215
216216 @Override
217217 public int read(byte[] buffer, int offset, int count) throws IOException {
218- final int read;
219- int readCount = count;
218+ final int read;
219+ int readCount = count;
220220 final long contentLength = mContentLength.get();
221221 long seekOffsetRead;
222- synchronized (mSeekOffsetReadStream) {
223- seekOffsetRead = mSeekOffsetReadStream.get();
224- if (contentLength >= 0 && seekOffsetRead == contentLength) {
225- assert seekOffsetRead == getOffsetWritten();
226- // ファイル終端
227- read = -1;
228- } else {
229- final int remainFileLength = (int) (getOffsetWritten() - seekOffsetRead);
230- if (readCount > remainFileLength) {
231- readCount = remainFileLength;
232- }
233- final int remainBufferLength = buffer.length - offset;
234- if (readCount > remainBufferLength) {
235- readCount = remainBufferLength;
236- }
237-// if (readCount < 0) {
238-// if (DEBUG_LOGD) {
239-// Log.d(LOG_TAG, "readCount becomes 0!");
240-// }
241-// readCount = 0;
242-// }
222+ int remainFileLength = -1;
223+ try {
224+ synchronized (mSeekOffsetReadStream) {
225+ seekOffsetRead = mSeekOffsetReadStream.get();
226+ if (contentLength >= 0 && seekOffsetRead == contentLength) {
227+ assert seekOffsetRead == getOffsetWritten();
228+ // ファイル終端
229+ read = -1;
230+ } else {
231+ remainFileLength = (int) (getOffsetWritten() - seekOffsetRead);
232+ if (readCount > remainFileLength) {
233+ readCount = remainFileLength;
234+ }
235+ final int remainBufferLength = buffer.length - offset;
236+ if (readCount > remainBufferLength) {
237+ readCount = remainBufferLength;
238+ }
239+// if (readCount < 0) {
240+// if (DEBUG_LOGD) {
241+// Log.d(LOG_TAG, "readCount becomes 0!");
242+// }
243+// readCount = 0;
244+// }
243245
244- mLockFile.lock();
245- try {
246- mFile.seek(seekOffsetRead);
247- read = mFile.read(buffer, offset, readCount);
248- } finally {
249- mLockFile.unlock();
250- }
251- if (read >= 0) {
252- seekOffsetRead += read;
253- mSeekOffsetReadStream.set(seekOffsetRead);
254- }
246+ mLockFile.lock();
247+ try {
248+ mFile.seek(seekOffsetRead);
249+ read = mFile.read(buffer, offset, readCount);
250+ } finally {
251+ mLockFile.unlock();
252+ }
253+ if (read >= 0) {
254+ seekOffsetRead += read;
255+ mSeekOffsetReadStream.set(seekOffsetRead);
256+ }
257+ }
258+ }
259+ if (DEBUG_LOGD_INPUT_STREAM) {
260+ Log.d(LOG_TAG, Log.buf().append(getClass().getName())
261+ .append("#read(")
262+ .append(buffer.toString()).append(',').append(offset)
263+ .append(',').append(count)
264+ .append(") readCount=").append(readCount)
265+ .append(" return=").append(read)
266+ .append(" seekOffsetRead=").append(seekOffsetRead)
267+ .append(" seekOffsetWrite=").append(mSeekOffsetWrite.get())
268+ .append(" contentLength=").append(contentLength)
269+ .toString());
255270 }
256- }
257- if (DEBUG_LOGD_INPUT_STREAM) {
258- Log.d(LOG_TAG, Log.buf().append(getClass().getName())
259- .append("#read(")
260- .append(buffer.toString()).append(',').append(offset)
261- .append(',').append(count)
262- .append(") readCount=").append(readCount)
263- .append(" return=").append(read)
264- .append(" seekOffsetRead=").append(seekOffsetRead)
265- .append(" seekOffsetWrite=").append(mSeekOffsetWrite.get())
266- .append(" contentLength=").append(contentLength)
267- .toString());
268- }
269- return read;
271+ return read;
272+ } catch (IOException e) {
273+ throw e;
274+ } catch (Exception e) {
275+ // FIXME クラッシュ解析向け
276+ String detailMessage = "original count=" + count
277+ + ", readCount=" + readCount
278+ + ", remainFileLength=" + remainFileLength;
279+ throw new RuntimeException(detailMessage, e);
280+ }
270281 }
271282
272283 @Override
--- trunk/NicoRo/src/jp/sourceforge/nicoro/VideoProxyHttpServer.java (revision 571)
+++ trunk/NicoRo/src/jp/sourceforge/nicoro/VideoProxyHttpServer.java (revision 572)
@@ -516,6 +516,11 @@
516516 // TODO
517517 Log.e(LOG_TAG, e.toString(), e);
518518 getHandler().sendEmptyMessage(MSG_ID_SC_CLOSE);
519+ } catch (Exception e) {
520+ // FIXME クラッシュ解析向け
521+ String detailMessage = "mRangeEnd=" + mRangeEnd
522+ + ", mReadLength=" + mReadLength;
523+ throw new RuntimeException(detailMessage, e);
519524 }
520525 } break;
521526 case MSG_ID_SC_SKIP_STREAM: {
Show on old repository browser