Skip to content

Commit 981579b

Browse files
committed
Improved comments
1 parent 117ec56 commit 981579b

2 files changed

Lines changed: 22 additions & 27 deletions

File tree

phase4-lib/src/main/java/com/helger/phase4/util/AS4ResourceHelper.java

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@
4444
import com.helger.phase4.logging.Phase4LoggerFactory;
4545

4646
/**
47-
* A resource manager that keeps track of temporary files and other closables
48-
* that will be closed when this manager is closed. When calling
49-
* {@link #createTempFile()} a new filename is created and added to the list.
50-
* When using {@link #addCloseable(Closeable)} the Closable is added for
47+
* A resource manager that keeps track of temporary files and other closables that will be closed
48+
* when this manager is closed. When calling {@link #createTempFile()} a new filename is created and
49+
* added to the list. When using {@link #addCloseable(Closeable)} the Closable is added for
5150
* postponed closing.
5251
*
5352
* @author Philip Helger
@@ -61,8 +60,7 @@ public class AS4ResourceHelper implements Closeable
6160
private static File s_aTempDir;
6261

6362
/**
64-
* @return The temp file directory to use, or <code>null</code> for the system
65-
* default.
63+
* @return The temp file directory to use, or <code>null</code> for the system default.
6664
*/
6765
@Nullable
6866
public static File getTempDir ()
@@ -74,8 +72,8 @@ public static File getTempDir ()
7472
* Set a temporary directory to use.
7573
*
7674
* @param aTempDir
77-
* The directory to use. It must be an existing directory. May be
78-
* <code>null</code> to use the system default.
75+
* The directory to use. It must be an existing directory. May be <code>null</code> to use
76+
* the system default.
7977
* @throws IllegalArgumentException
8078
* If the directory does not exist
8179
*/
@@ -100,8 +98,8 @@ public AS4ResourceHelper ()
10098
{}
10199

102100
/**
103-
* @return A new temporary {@link File} that will be deleted when
104-
* {@link #close()} is called.
101+
* @return A new temporary {@link File} that will be deleted when {@link #close()} is called on
102+
* this instance.
105103
* @throws IOException
106104
* When temp file creation fails.
107105
* @throws IllegalStateException
@@ -130,8 +128,7 @@ public File createTempFile () throws IOException
130128
}
131129

132130
/**
133-
* @return A list of all known temp files. Never <code>null</code> but maybe
134-
* empty.
131+
* @return A list of all known temp files. Never <code>null</code> but maybe empty.
135132
* @since 0.8.3
136133
*/
137134
@Nonnull
@@ -160,8 +157,7 @@ public void addCloseable (@Nonnull final Closeable aCloseable)
160157
}
161158

162159
/**
163-
* @return A list of all known closables. Never <code>null</code> but maybe
164-
* empty.
160+
* @return A list of all known closables. Never <code>null</code> but maybe empty.
165161
* @since 0.8.3
166162
*/
167163
@Nonnull
@@ -194,17 +190,17 @@ public void close ()
194190
}
195191

196192
// Get and delete all temp files
197-
final ICommonsList <File> aFiles = m_aRWLock.writeLockedGet ( () -> {
193+
final ICommonsList <File> aTempFiles = m_aRWLock.writeLockedGet ( () -> {
198194
final ICommonsList <File> ret = m_aTempFiles.getClone ();
199195
m_aTempFiles.clear ();
200196
return ret;
201197
});
202-
if (aFiles.isNotEmpty ())
198+
if (aTempFiles.isNotEmpty ())
203199
{
204200
if (LOGGER.isDebugEnabled ())
205-
LOGGER.debug ("Deleting " + aFiles.size () + " temporary " + CAS4.LIB_NAME + " files");
201+
LOGGER.debug ("Deleting " + aTempFiles.size () + " temporary " + CAS4.LIB_NAME + " files");
206202

207-
for (final File aFile : aFiles)
203+
for (final File aFile : aTempFiles)
208204
{
209205
if (LOGGER.isDebugEnabled ())
210206
LOGGER.debug ("Deleting temporary file '" + aFile.getAbsolutePath () + "'");
@@ -223,14 +219,12 @@ public void close ()
223219
}
224220

225221
/**
226-
* Ensure the provided {@link HttpEntity} can be read more than once. If the
227-
* provided entity is not repeatable a temporary file is created and a new
228-
* file-based Http Entity is created.
222+
* Ensure the provided {@link HttpEntity} can be read more than once. If the provided entity is
223+
* not repeatable a temporary file is created and a new file-based Http Entity is created.
229224
*
230225
* @param aSrcEntity
231226
* The source Http entity. May not be <code>null</code>.
232-
* @return A non-<code>null</code> Http entity that can be read more than
233-
* once.
227+
* @return A non-<code>null</code> Http entity that can be read more than once.
234228
* @throws IOException
235229
* on IO error
236230
* @since v0.9.9

phase4-peppol-client/src/main/java/com/helger/phase4/peppol/Phase4PeppolSender.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,18 +1393,19 @@ protected ESuccess finishFields (@Nonnull final AS4ResourceHelper aResHelper) th
13931393
if (m_aSBDDocumentConsumer != null)
13941394
m_aSBDDocumentConsumer.accept (aSBD);
13951395

1396-
if (true)
1396+
if (false)
13971397
{
13981398
// Serialize the SBDH to a temporary file
1399+
// Advantage: works with large files as well because it consumes less memory
13991400
// Drawback: will not call the SBDH Byte Consumer
14001401
try
14011402
{
1402-
final File fTempSBD = aResHelper.createTempFile ();
1403-
new SBDMarshaller ().write (aSBD, fTempSBD);
1403+
final File aTempSBDFile = aResHelper.createTempFile ();
1404+
new SBDMarshaller ().write (aSBD, aTempSBDFile);
14041405

14051406
// Now we have the main payload
14061407
payload (AS4OutgoingAttachment.builder ()
1407-
.data (fTempSBD)
1408+
.data (aTempSBDFile)
14081409
.mimeType (m_aPayloadMimeType)
14091410
.compression (m_bCompressPayload ? EAS4CompressionMode.GZIP : null)
14101411
.contentID (m_sPayloadContentID));

0 commit comments

Comments
 (0)