X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=core%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2FReaderException.java;h=0d8a3d53858d0732b0387dba8b145d53a2c047e8;hb=a96a22b731c6402277a70ca54ccec32088adbfbb;hp=e7172794be723e0f15c02516a3cc6a7f6eca25c9;hpb=9dc2a42f1e2a05cd525d4e583e6127eda8e7c4de;p=zxing.git diff --git a/core/src/com/google/zxing/ReaderException.java b/core/src/com/google/zxing/ReaderException.java index e7172794..0d8a3d53 100644 --- a/core/src/com/google/zxing/ReaderException.java +++ b/core/src/com/google/zxing/ReaderException.java @@ -1,5 +1,5 @@ /* - * Copyright 2007 Google Inc. + * Copyright 2007 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,16 +20,35 @@ package com.google.zxing; * The general exception class throw when something goes wrong during decoding of a barcode. * This includes, but is not limited to, failing checksums / error correction algorithms, being * unable to locate finder timing patterns, and so on. - * - * @author srowen@google.com (Sean Owen) + * + * @author Sean Owen */ public final class ReaderException extends Exception { - public ReaderException() { + // TODO: Currently we throw up to 400 ReaderExceptions while scanning a single 240x240 image before + // rejecting it. This involves a lot of overhead and memory allocation, and affects both performance + // and latency on continuous scan clients. In the future, we should change all the decoders not to + // throw exceptions for routine events, like not finding a barcode on a given row. Instead, we + // should return error codes back to the callers, and simply delete this class. In the mean time, I + // have altered this class to be as lightweight as possible, by ignoring the exception string, and + // by disabling the generation of stack traces, which is especially time consuming. These are just + // temporary measures, pending the big cleanup. + + private static final ReaderException instance = new ReaderException(); + + private ReaderException() { + // do nothing + } + + public static ReaderException getInstance() { + return instance; } - public ReaderException(String message) { - super(message); + // Prevent stack traces from being taken + // srowen says: huh, my IDE is saying this is not an override. native methods can't be overridden? + // This, at least, does not hurt. Because we use a singleton pattern here, it doesn't matter anyhow. + public Throwable fillInStackTrace() { + return null; } }