Uploaded image for project: 'Accumulo'
  1. Accumulo
  2. ACCUMULO-4067

TTimeoutTransport repeatedly uses reflection to obtain method

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.6.5, 1.7.1, 1.8.0
    • Component/s: rpc
    • Labels:
      None

      Description

      Noticed the following in TTimeoutTransport while looking at ACCUMULO-4065:

        private static InputStream getInputStream(Socket socket, long timeout) {
          try {
            Method m = NetUtils.class.getMethod("getInputStream", Socket.class, Long.TYPE);
            return (InputStream) m.invoke(null, socket, timeout);
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
      

      We should really just invoke getMethod once and cache the Method instance instead of repeatedly getting it every time we create a new connection (which is often).

      Not sure if this is a "hot" enough code path to have a noticeable performance impact, but it should be good to fix regardless.

        Attachments

          Activity

            People

            • Assignee:
              elserj Josh Elser
              Reporter:
              elserj Josh Elser
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h