@@ -54,6 +54,7 @@ public abstract class Purchase {
5454 private static final String RECEIPTS_REFRESH_TIME_KEY = "CN1SubscriptionsDataRefreshTime.dat" ;
5555 private static final String PENDING_PURCHASE_KEY = "PendingPurchases.dat" ;
5656 private static final Object synchronizationLock = new Object ();
57+ private static final Object receiptsLock = new Object ();
5758 private static ReceiptStore receiptStore ;
5859 private static List <Receipt > receipts ;
5960 private static Date receiptsRefreshTime ;
@@ -131,7 +132,7 @@ public final void setReceiptStore(ReceiptStore store) {
131132 * @return List of receipts for purchases this app.
132133 */
133134 public final List <Receipt > getReceipts () {
134- synchronized (RECEIPTS_KEY ) {
135+ synchronized (receiptsLock ) {
135136 if (receipts == null ) {
136137 if (Storage .getInstance ().exists (RECEIPTS_KEY )) {
137138 Receipt .registerExternalizable ();
@@ -157,7 +158,7 @@ public final List<Receipt> getReceipts() {
157158 * @param data
158159 */
159160 private void setReceipts (List <Receipt > data ) {
160- synchronized (RECEIPTS_KEY ) {
161+ synchronized (receiptsLock ) {
161162 receipts = new ArrayList <Receipt >();
162163 receipts .addAll (data );
163164 Storage .getInstance ().writeObject (RECEIPTS_KEY , receipts );
@@ -187,7 +188,7 @@ public final Receipt[] getReceipts(String... skus) {
187188 * @return
188189 */
189190 private Date getReceiptsRefreshTime () {
190- synchronized (RECEIPTS_KEY ) {
191+ synchronized (receiptsLock ) {
191192 if (receiptsRefreshTime == null ) {
192193 if (Storage .getInstance ().exists (RECEIPTS_REFRESH_TIME_KEY )) {
193194 receiptsRefreshTime = (Date ) Storage .getInstance ().readObject (RECEIPTS_REFRESH_TIME_KEY );
@@ -205,7 +206,7 @@ private Date getReceiptsRefreshTime() {
205206 * @param time
206207 */
207208 private void setReceiptsRefreshTime (Date time ) {
208- synchronized (RECEIPTS_KEY ) {
209+ synchronized (receiptsLock ) {
209210 receiptsRefreshTime = time ;
210211 Storage .getInstance ().writeObject (RECEIPTS_REFRESH_TIME_KEY , receiptsRefreshTime );
211212 }
@@ -569,15 +570,16 @@ public void onSucess(Boolean value) {
569570
570571 public void run () {
571572
572- while (!complete [0 ]) {
573- synchronized (complete ) {
574- try {
575- complete .wait ();
576- } catch (Exception ex ) {
577-
573+ while (!complete [0 ]) {
574+ synchronized (complete ) {
575+ try {
576+ complete .wait ();
577+ } catch (InterruptedException ex ) {
578+ Thread .currentThread ().interrupt ();
579+ return ;
580+ }
578581 }
579582 }
580- }
581583 }
582584
583585 });
@@ -777,8 +779,9 @@ public void run() {
777779 synchronized (complete ) {
778780 try {
779781 complete .wait ();
780- } catch (Exception ex ) {
781-
782+ } catch (InterruptedException ex ) {
783+ Thread .currentThread ().interrupt ();
784+ return ;
782785 }
783786 }
784787 }
0 commit comments