Produced by Araxis Merge on 3/25/2019 8:57:59 AM 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.
# | Location | File | Last Modified |
---|---|---|---|
1 | C:\AraxisMergeCompare\Pri_un\IMAG_Source\VISA\Java\CacheImplJCIFS\main\src\java\gov\va\med\imaging\storage\cache\impl\jcifs | InstanceWritableByteChannelImpl.java | Mon Mar 18 20:39:17 2019 UTC |
2 | C:\AraxisMergeCompare\Pri_re\IMAG_Source\VISA\Java\CacheImplJCIFS\main\src\java\gov\va\med\imaging\storage\cache\impl\jcifs | InstanceWritableByteChannelImpl.java | Tue Mar 19 12:03:22 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 278 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
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 |
No regular expressions were active.
1 | package go v.va.med.i maging.sto rage.cache .impl.jcif s; | |
2 | ||
3 | import gov .va.med.im aging.stor age.cache. InstanceWr itableByte Channel; | |
4 | import gov .va.med.im aging.stor age.cache. exceptions .Simultane ousWriteEx ception; | |
5 | ||
6 | import jav a.io.IOExc eption; | |
7 | import jav a.io.Outpu tStream; | |
8 | import jav a.nio.Byte Buffer; | |
9 | import jav a.nio.chan nels.Chann els; | |
10 | import jav a.nio.chan nels.Writa bleByteCha nnel; | |
11 | import jav a.util.zip .Checksum; | |
12 | ||
13 | import org .apache.lo gging.log4 j.LogManag er; | |
14 | import org .apache.lo gging.log4 j.Logger; | |
15 | ||
16 | import jci fs.smb.Smb File; | |
17 | ||
18 | /** | |
19 | * A class that simp ly wraps a FileChann el that wi ll be used for writi ng, | |
20 | * and rel eases a lo ck when th e channel is closed. | |
21 | * | |
22 | * @author DN S BECKEC | |
23 | * | |
24 | */ | |
25 | class Inst anceWritab leByteChan nelImpl | |
26 | implements InstanceW ritableByt eChannel | |
27 | { | |
28 | /* * | |
29 | * | |
30 | * / | |
31 | pr ivate fina l JcifsByt eChannelFa ctory fact ory; | |
32 | pr ivate fina l SmbFile file; | |
33 | pr ivate fina l OutputSt ream outSt ream; | |
34 | pr ivate fina l Writable ByteChanne l wrappedC hannel; | |
35 | pr ivate long openedTim e = 0L; // keep this so th at we coul d close th e files ou rselves if the clien t does not | |
36 | pr ivate long lastAcces sedTime = 0L; | |
37 | pr ivate Chec ksum check sum; | |
38 | pr ivate Stac kTraceElem ent[] inst antiatingS tackTrace = null; | |
39 | ||
40 | In stanceWrit ableByteCh annelImpl( JcifsByteC hannelFact ory factor y, SmbFile file) | |
41 | th rows IOExc eption, Si multaneous WriteExcep tion | |
42 | { | |
43 | this (factory, file, null ); | |
44 | } | |
45 | ||
46 | In stanceWrit ableByteCh annelImpl( JcifsByteC hannelFact ory factor y, SmbFile file, Che cksum chec ksum) | |
47 | th rows IOExc eption, Si multaneous WriteExcep tion | |
48 | { | |
49 | this .factory = factory; | |
50 | this .file = fi le; | |
51 | this .checksum = checksum ; | |
52 | ||
53 | this .factory.l og.debug(" InstanceWr itableByte ChannelImp l, opening '" + file .getPath() + "'" ); | |
54 | if(t his.factor y.isTraceC hannelInst antiation( )) | |
55 | instan tiatingSta ckTrace = Thread.cur rentThread ().getStac kTrace(); | |
56 | outS tream = fi le.getOutp utStream() ; | |
57 | wrap pedChannel = Channel s.newChann el(outStre am); | |
58 | ||
59 | open edTime = S ystem.curr entTimeMil lis(); | |
60 | last AccessedTi me = opene dTime; | |
61 | } | |
62 | ||
63 | Sm bFile getF ile() | |
64 | { | |
65 | retu rn this.fi le; | |
66 | } | |
67 | ||
68 | pu blic Stack TraceEleme nt[] getIn stantiatin gStackTrac e() | |
69 | { | |
70 | retu rn instant iatingStac kTrace; | |
71 | } | |
72 | ||
73 | pu blic long getLastAcc essedTime( ) | |
74 | { | |
75 | retu rn lastAcc essedTime; | |
76 | } | |
77 | ||
78 | pu blic Check sum getChe cksum() | |
79 | { | |
80 | retu rn this.ch ecksum; | |
81 | } | |
82 | ||
83 | /* * | |
84 | * Write fro m an NIO B yteBuffer to a strea m | |
85 | * / | |
86 | pu blic int w rite(ByteB uffer src) | |
87 | th rows IOExc eption | |
88 | { | |
89 | Chec ksum local ChecksumRe f = getChe cksum(); // just for perfor mance | |
90 | if(l ocalChecks umRef != n ull) | |
91 | for(By teBuffer l ocalBuffer = src.asR eadOnlyBuf fer(); loc alBuffer.h asRemainin g(); local ChecksumRe f.update(l ocalBuffer .get()) ); | |
92 | ||
93 | last AccessedTi me = Syste m.currentT imeMillis( ); | |
94 | ||
95 | retu rn wrapped Channel.wr ite(src); | |
96 | } | |
97 | ||
98 | pu blic void close() | |
99 | th rows IOExc eption | |
100 | { | |
101 | clos e(false); | |
102 | } | |
103 | ||
104 | /* (non-Java doc) | |
105 | * @see gov. va.med.ima ging.stora ge.cache.i mpl.filesy stem.Insta nceWritabl eByteChann el#error() | |
106 | * / | |
107 | pu blic void error() | |
108 | th rows IOExc eption | |
109 | { | |
110 | clos e(true); | |
111 | } | |
112 | ||
113 | pr ivate void close(boo lean error Close) | |
114 | th rows IOExc eption | |
115 | { | |
116 | this .factory.l og.debug(" InstanceWr itableByte ChannelImp l, closing '" + file .getPath() + "' " + (errorClos e ? "WITH" : "withou t") + " de lete"); | |
117 | ||
118 | try{ wrappedCh annel.clos e(); } | |
119 | catc h(IOExcept ion e) | |
120 | {thi s.factory. log.warn(e );} // the channel m ay already be closed through s ome error or other t imeout, lo g it but k eep going | |
121 | ||
122 | try{ outStream .close(); } | |
123 | catc h(IOExcept ion e) | |
124 | {thi s.factory. log.warn(e );} | |
125 | ||
126 | if( errorClose ) | |
127 | this.f ile.delete (); | |
128 | ||
129 | // t he followi ng operati on really must occur regardles s of the | |
130 | // s uccess of the previo us IO oper ations, el se threads will lock and byte channels w ill repeat edly be cl osed when they are a lready clo sed | |
131 | this .factory.w ritableByt eChannelCl osed(this, errorClos e); | |
132 | ||
133 | this .factory.l og.debug(" InstanceWr itableByte ChannelImp l - '" + f ile.getPat h() + "' c losed " + (errorClos e ? "WITH" : "withou t") + " de lete"); | |
134 | } | |
135 | ||
136 | pu blic boole an isOpen( ) | |
137 | { | |
138 | retu rn wrapped Channel != null && w rappedChan nel.isOpen (); | |
139 | } | |
140 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.