210. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 9/25/2018 2:13:13 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

210.1 Files compared

# Location File Last Modified
1 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\sun\net\www\http KeepAliveCache.java Mon Jan 22 14:46:54 2018 UTC
2 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\sun\net\www\http KeepAliveCache.java Wed Sep 12 17:45:17 2018 UTC

210.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 692
Changed 1 2
Inserted 0 0
Removed 0 0

210.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

210.4 Active regular expressions

No regular expressions were active.

210.5 Comparison detail

  1   /*
  2    * Copyrig ht (c) 199 6, 2011, O racle and/ or its aff iliates. A ll rights  reserved.
  3    * DO NOT  ALTER OR R EMOVE COPY RIGHT NOTI CES OR THI S FILE HEA DER.
  4    *
  5    * This co de is free  software;  you can r edistribut e it and/o r modify i t
  6    * under t he terms o f the GNU  General Pu blic Licen se version  2 only, a s
  7    * publish ed by the  Free Softw are Founda tion.  Ora cle design ates this
  8    * particu lar file a s subject  to the "Cl asspath" e xception a s provided
  9    * by Orac le in the  LICENSE fi le that ac companied  this code.
  10    *
  11    * This co de is dist ributed in  the hope  that it wi ll be usef ul, but WI THOUT
  12    * ANY WAR RANTY; wit hout even  the implie d warranty  of MERCHA NTABILITY  or
  13    * FITNESS  FOR A PAR TICULAR PU RPOSE.  Se e the GNU  General Pu blic Licen se
  14    * version  2 for mor e details  (a copy is  included  in the LIC ENSE file  that
  15    * accompa nied this  code).
  16    *
  17    * You sho uld have r eceived a  copy of th e GNU Gene ral Public  License v ersion
  18    * 2 along  with this  work; if  not, write  to the Fr ee Softwar e Foundati on,
  19    * Inc., 5 1 Franklin  St, Fifth  Floor, Bo ston, MA 0 2110-1301  USA.
  20    *
  21    * Please  contact Or acle, 500  Oracle Par kway, Redw ood Shores , CA 94065  USA
  22    * or visi t www.orac le.com if  you need a dditional  informatio n or have  any
  23    * questio ns.
  24    */
  25  
  26   package su n.net.www. http;
  27  
  28   import jav a.io.IOExc eption;
  29   import jav a.io.NotSe rializable Exception;
  30   import jav a.util.Arr ayList;
  31   import jav a.util.Has hMap;
  32   import jav a.net.URL;
  33  
  34   /**
  35    * A class  that impl ements a c ache of id le Http co nnections  for keep-a live
  36    *
  37    * @author  Stephen R . Pietrowi cz (NCSA)
  38    * @author  Dave Brow n
  39    */
  40   public cla ss KeepAli veCache
  41       extend s HashMap< KeepAliveK ey, Client Vector>
  42       implem ents Runna ble {
  43       privat e static f inal long  serialVers ionUID = - 2937172892 064557949L ;
  44  
  45       /* max imum # kee p-alive co nnections  to maintai n at once
  46        * Thi s should b e 2 by the  HTTP spec , but beca use we don 't support  pipe-lini ng
  47        * a l arger valu e is more  appropriat e. So we n ow set a d efault of  5, and the  value
  48        * ref ers to the  number of  idle conn ections pe r destinat ion (in th e cache) o nly.
  49        * It  can be res et by sett ing system  property  "http.maxC onnections ".
  50        */
  51       static  final int  MAX_CONNE CTIONS = 5 ;
  52       static  int resul t = -1;
  53       static  int getMa xConnectio ns() {
  54           if  (result = = -1) {
  55                result =  java.secu rity.Acces sControlle r.doPrivil eged(
  56                    new  sun.securi ty.action. GetInteger Action("ht tp.maxConn ections",
  57                                                                 MAX _CONNECTIO NS))
  58                    .int Value();
  59                if (resu lt <= 0)
  60                    resu lt = MAX_C ONNECTIONS ;
  61           }
  62                return r esult;
  63       }
  64  
  65       static  final int  LIFETIME  = 5000;
  66  
  67       privat e Thread k eepAliveTi mer = null ;
  68  
  69       /**
  70        * Con structor
  71        */
  72       public  KeepAlive Cache() {}
  73  
  74       /**
  75        * Reg ister this  URL and H ttpClient  (that supp orts keep- alive) wit h the cach e
  76        * @pa ram url  T he URL con tains info  about the  host and  port
  77        * @pa ram http T he HttpCli ent to be  cached
  78        */
  79       public  synchroni zed void p ut(final U RL url, Ob ject obj,  HttpClient  http) {
  80           bo olean star tThread =  (keepAlive Timer == n ull);
  81           if  (!startTh read) {
  82                if (!kee pAliveTime r.isAlive( )) {
  83                    star tThread =  true;
  84                }
  85           }
  86           if  (startThr ead) {
  87                clear();
  88                /* Unfor tunately,  we can't a lways beli eve the ke ep-alive t imeout we  got
  89                 * back  from the s erver.  If  I'm conne cted throu gh a Netsc ape proxy
  90                 * to a  server tha t sent me  a keep-ali ve
  91                 * time  of 15 sec,  the proxy  unilatera lly termin ates my co nnection
  92                 * The r obustness  to get aro und this i s in HttpC lient.pars eHTTP()
  93                 */
  94                final Ke epAliveCac he cache =  this;
  95                java.sec urity.Acce ssControll er.doPrivi leged(
  96                    new  java.secur ity.Privil egedAction <Void>() {
  97                    publ ic Void ru n() {
  98                       / / We want  to create  the Keep-A live-Timer  in the
  99                         // system  threadgrou p
  100                         ThreadGrou p grp = Th read.curre ntThread() .getThread Group();
  101                         ThreadGrou p parent =  null;
  102                         while ((pa rent = grp .getParent ()) != nul l) {
  103                             grp =  parent;
  104                         }
  105  
  106                         keepAliveT imer = new  Thread(gr p, cache,  "Keep-Aliv e-Timer");
  107                         keepAliveT imer.setDa emon(true) ;
  108                         keepAliveT imer.setPr iority(Thr ead.MAX_PR IORITY - 2 );
  109                         // Set the  context c lass loade r to null  in order t o avoid
  110                         // keeping  a strong  reference  to an appl ication cl assloader.
  111                         keepAliveT imer.setCo ntextClass Loader(nul l);
  112                         keepAliveT imer.start ();
  113                         return nul l;
  114                    }
  115                });
  116           }
  117  
  118           Ke epAliveKey  key = new  KeepAlive Key(url, o bj);
  119           Cl ientVector  v = super .get(key);
  120  
  121           if  (v == nul l) {
  122                int keep AliveTimeo ut = http. getKeepAli veTimeout( );
  123                v = new  ClientVect or(keepAli veTimeout  > 0?
  124                                       keepAli veTimeout* 1000 : LIF ETIME);
  125                v.put(ht tp);
  126                super.pu t(key, v);
  127           }  else {
  128                v.put(ht tp);
  129           }
  130       }
  131  
  132       /* rem ove an obs olete Http Client fro m its Vect orCache */
  133       public  synchroni zed void r emove (Htt pClient h,  Object ob j) {
  134           Ke epAliveKey  key = new  KeepAlive Key(h.url,  obj);
  135           Cl ientVector  v = super .get(key);
  136           if  (v != nul l) {
  137                v.remove (h);
  138                if (v.em pty()) {
  139                    remo veVector(k ey);
  140                }
  141           }
  142       }
  143  
  144       /* cal led by a c lientVecto r thread w hen all it s connecti ons have t imed out
  145        * and  that vect or of conn ections sh ould be re moved.
  146        */
  147       synchr onized voi d removeVe ctor(KeepA liveKey k)  {
  148           su per.remove (k);
  149       }
  150  
  151       /**
  152        * Che ck to see  if this UR L has a ca ched HttpC lient
  153        */
  154       public  synchroni zed HttpCl ient get(U RL url, Ob ject obj)  {
  155  
  156           Ke epAliveKey  key = new  KeepAlive Key(url, o bj);
  157           Cl ientVector  v = super .get(key);
  158           if  (v == nul l) { // no thing in c ache yet
  159                return n ull;
  160           }
  161           re turn v.get ();
  162       }
  163  
  164       /* Sle eps for an  alloted t imeout, th en checks  for timed  out connec tions.
  165        * Err s on the s ide of cau tion (leav e connecti ons idle f or a relat ively
  166        * sho rt time).
  167        */
  168       @Overr ide
  169       public  void run( ) {
  170           do  {
  171                try {
  172                    Thre ad.sleep(L IFETIME);
  173                } catch  (Interrupt edExceptio n e) {}
  174                synchron ized (this ) {
  175                    /* R emove all  unused Htt pClients.   Starting  from the
  176                     * b ottom of t he stack ( the least- recently u sed first) .
  177                     * R EMIND: It' d be nice  to not rem ove *all*  connection s
  178                     * t hat aren't  presently  in use.   One could  have been  added
  179                     * a  second ag o that's s till perfe ctly valid , and we'r e
  180                     * n eedlessly  axing it.   But it's  not clear  how to do  this
  181                     * c leanly, an d doing it  right may  be more t rouble tha n it's
  182                     * w orth.
  183                     */
  184  
  185                    long  currentTi me = Syste m.currentT imeMillis( );
  186  
  187                    Arra yList<Keep AliveKey>  keysToRemo ve
  188                         = new Arra yList<Keep AliveKey>( );
  189  
  190                    for  (KeepAlive Key key :  keySet())  {
  191                         ClientVect or v = get (key);
  192                         synchroniz ed (v) {
  193                             int i;
  194  
  195                             for (i  = 0; i <  v.size();  i++) {
  196                                 Ke epAliveEnt ry e = v.e lementAt(i );
  197                                 if  ((current Time - e.i dleStartTi me) > v.na p) {
  198                                      HttpClie nt h = e.h c;
  199                                      h.closeS erver();
  200                                 }  else {
  201                                      break;
  202                                 }
  203                             }
  204                             v.subL ist(0, i). clear();
  205  
  206                             if (v. size() ==  0) {
  207                                 ke ysToRemove .add(key);
  208                             }
  209                         }
  210                    }
  211  
  212                    for  (KeepAlive Key key :  keysToRemo ve) {
  213                         removeVect or(key);
  214                    }
  215                }
  216           }  while (siz e() > 0);
  217  
  218           re turn;
  219       }
  220  
  221       /*
  222        * Do  not serial ize this c lass!
  223        */
  224       privat e void wri teObject(j ava.io.Obj ectOutputS tream stre am)
  225       throws  IOExcepti on {
  226           th row new No tSerializa bleExcepti on();
  227       }
  228  
  229       privat e void rea dObject(ja va.io.Obje ctInputStr eam stream )
  230       throws  IOExcepti on, ClassN otFoundExc eption {
  231           th row new No tSerializa bleExcepti on();
  232       }
  233   }
  234  
  235   /* FILO or der for re cycling Ht tpClients,  should ru n in a thr ead
  236    * to time  them out.   If > max Conns are  in use, bl ock.
  237    */
  238  
  239  
  240   class Clie ntVector e xtends jav a.util.Sta ck<KeepAli veEntry> {
  241       privat e static f inal long  serialVers ionUID = - 8680532108 106489459L ;
  242  
  243       // sle ep time in  milliseco nds, befor e cache cl ear
  244       int na p;
  245  
  246  
  247  
  248       Client Vector (in t nap) {
  249           th is.nap = n ap;
  250       }
  251  
  252       synchr onized Htt pClient ge t() {
  253           if  (empty())  {
  254                return n ull;
  255           }  else {
  256                // Loop  until we f ind a conn ection tha t has not  timed out
  257                HttpClie nt hc = nu ll;
  258                long cur rentTime =  System.cu rrentTimeM illis();
  259                do {
  260                    Keep AliveEntry  e = pop() ;
  261                    if ( (currentTi me - e.idl eStartTime ) > nap) {
  262                         e.hc.close Server();
  263                    } el se {
  264                         hc = e.hc;
  265                    }
  266                } while  ((hc== nul l) && (!em pty()));
  267                return h c;
  268           }
  269       }
  270  
  271       /* ret urn a stil l valid, u nused Http Client */
  272       synchr onized voi d put(Http Client h)  {
  273           if  (size() > = KeepAliv eCache.get MaxConnect ions()) {
  274                h.closeS erver(); / / otherwis e the conn ection rem ains in li mbo
  275           }  else {
  276                push(new  KeepAlive Entry(h, S ystem.curr entTimeMil lis()));
  277           }
  278       }
  279  
  280       /*
  281        * Do  not serial ize this c lass!
  282        */
  283       privat e void wri teObject(j ava.io.Obj ectOutputS tream stre am)
  284       throws  IOExcepti on {
  285           th row new No tSerializa bleExcepti on();
  286       }
  287  
  288       privat e void rea dObject(ja va.io.Obje ctInputStr eam stream )
  289       throws  IOExcepti on, ClassN otFoundExc eption {
  290           th row new No tSerializa bleExcepti on();
  291       }
  292   }
  293  
  294  
  295   class Keep AliveKey {
  296       privat e String       protoc ol = null;
  297       privat e String       host =  null;
  298         private in          PORT      
;
  299       privat e Object       obj =  null; // a dditional  key, such  as socketf actory
  300  
  301       /**
  302        * Con structor
  303        *
  304        * @pa ram url th e URL cont aining the  protocol,  host and  port infor mation
  305        */
  306       public  KeepAlive Key(URL ur l, Object  obj) {
  307           th is.protoco l = url.ge tProtocol( );
  308           th is.host =  url.getHos t();
  309           th is.port =  url.getPor t();
  310           th is.obj = o bj;
  311       }
  312  
  313       /**
  314        * Det ermine whe ther or no t two obje cts of thi s type are  equal
  315        */
  316       @Overr ide
  317       public  boolean e quals(Obje ct obj) {
  318           if  ((obj ins tanceof Ke epAliveKey ) == false )
  319                return f alse;
  320           Ke epAliveKey  kae = (Ke epAliveKey )obj;
  321           re turn host. equals(kae .host)
  322                && (port  == kae.po rt)
  323                && proto col.equals (kae.proto col)
  324                && this. obj == kae .obj;
  325       }
  326  
  327       /**
  328        * The  hashCode( ) for this  object is  the strin g hashCode () of
  329        * con catenation  of the pr otocol, ho st name an d port.
  330        */
  331       @Overr ide
  332       public  int hashC ode() {
  333           St ring str =  protocol+ host+port;
  334           re turn this. obj == nul l? str.has hCode() :
  335                str.hash Code() + t his.obj.ha shCode();
  336       }
  337   }
  338  
  339   class Keep AliveEntry  {
  340       HttpCl ient hc;
  341       long i dleStartTi me;
  342  
  343       KeepAl iveEntry(H ttpClient  hc, long i dleStartTi me) {
  344           th is.hc = hc ;
  345           th is.idleSta rtTime = i dleStartTi me;
  346       }
  347   }