Ticket #12935: 0001-12935-without-logging.patch

File 0001-12935-without-logging.patch, 1.9 KB (added by iwakeh, 5 years ago)

this should be logging free.

  • src/main/java/org/torproject/onionoo/docs/DateTimeHelper.java

    From 72ebe5c45271a40f1398d4342d785108ada1bb2a Mon Sep 17 00:00:00 2001
    From: ano nymous <no-mail@unknown.org>
    Date: Thu, 1 Jan 1970 00:00:00 +0000
    Subject: [PATCH] 12935 without logging.
    
    ---
     .../org/torproject/onionoo/docs/DateTimeHelper.java   | 19 +++++++++++++------
     .../org/torproject/onionoo/docs/UptimeHistory.java    |  2 +-
     2 files changed, 14 insertions(+), 7 deletions(-)
    
    diff --git a/src/main/java/org/torproject/onionoo/docs/DateTimeHelper.java b/src/main/java/org/torproject/onionoo/docs/DateTimeHelper.java
    index 78aa78f..ee09ccd 100644
    a b import java.util.TimeZone; 
    1111
    1212public class DateTimeHelper {
    1313
     14  public final static long NO_TIME_AVAILABLE = -1L;
     15
    1416  private DateTimeHelper() {
    1517  }
    1618
    public class DateTimeHelper { 
    7984  }
    8085
    8186  public static long parse(String string, String format) {
     87    if (null == string) {
     88      return NO_TIME_AVAILABLE;
     89    }
    8290    try {
    8391      return getDateFormat(format).parse(string).getTime();
    8492    } catch (ParseException e) {
    85       return -1L;
     93      return NO_TIME_AVAILABLE;
    8694    }
    8795  }
    8896
    public class DateTimeHelper { 
    9098    return parse(string, ISO_DATETIME_FORMAT);
    9199  }
    92100}
    93 
  • src/main/java/org/torproject/onionoo/docs/UptimeHistory.java

    diff --git a/src/main/java/org/torproject/onionoo/docs/UptimeHistory.java b/src/main/java/org/torproject/onionoo/docs/UptimeHistory.java
    index d2655d5..ebe8795 100644
    a b public class UptimeHistory 
    3939    }
    4040    long startMillis = DateTimeHelper.parse(parts[1],
    4141          DateTimeHelper.DATEHOUR_NOSPACE_FORMAT);
    42     if (startMillis < 0L) {
     42    if (startMillis == DateTimeHelper.NO_TIME_AVAILABLE) {
    4343      return null;
    4444    }
    4545    int uptimeHours = -1;