Skip to content

Commit

Permalink
Fix tmp file handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed May 23, 2022
1 parent f4f363c commit 8ff44d1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Proteus Changelog.
## Unreleased
### No issue

**Better generic support.**


[f4f363ccb6e99eb](https://github.com/noboomu/proteus/commit/f4f363ccb6e99eb) Joshua Bauer *2022-04-22 00:00:28*

**Added support for last-modified using java.time.Instant.**


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,19 @@ protected java.nio.file.Path getTemporaryDirectoryPath() throws Exception

String tmpDirLocation = System.getProperty("java.io.tmpdir");

java.nio.file.Path tmpPath = Paths.get(tmpDirLocation).resolve(TMP_DIRECTORY_NAME);
java.nio.file.Path tmpPath = Paths.get(tmpDirLocation);

if (Files.exists(tmpPath))
try
{
return tmpPath;
}
else
return Files.createDirectory(tmpPath.resolve(TMP_DIRECTORY_NAME));

} catch (Exception e)
{
return Files.createDirectory(tmpPath);
return tmpPath;
}
}
}

}

protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class<?> clazz) throws Exception
{
Expand Down Expand Up @@ -367,9 +369,9 @@ else if (t.equals(HttpServerExchange.class) || t.equals(ServerRequest.class))
.collect(Collectors.toMap(java.util.function.Function.identity(), HandlerGenerator::typeReferenceNameForType));

parameterizedLiteralsNameMap
.forEach((t, n) -> initBuilder.addStatement("final $T<$L> $LTypeReference = new $T<$L>(){}", TypeReference.class, t, n, TypeReference.class, t));
.forEach((t, n) -> initBuilder.addStatement("final $T<$L> $LTypeReference = new $T<$L>(){}", TypeReference.class, t, n.replaceAll("[<>]+", ""), TypeReference.class, t));

literalsNameMap.forEach((t, n) -> initBuilder.addStatement("final $T<$T> $LTypeReference = new $T<$T>(){}", TypeReference.class, t, n, TypeReference.class, t));
literalsNameMap.forEach((t, n) -> initBuilder.addStatement("final $T<$T> $LTypeReference = new $T<$T>(){}", TypeReference.class, t, n.replaceAll("[<>]+", ""), TypeReference.class, t));

Optional<io.sinistral.proteus.annotations.Chain> typeLevelWrapAnnotation = Optional.ofNullable(clazz.getAnnotation(io.sinistral.proteus.annotations.Chain.class));

Expand Down Expand Up @@ -1298,15 +1300,11 @@ else if (matches > 2)
return null;
}


protected static String typeReferenceNameForParameterizedType(Type type)
{

String typeName = type.getTypeName();




if (typeName.contains("Optional"))
{
log.warn("Type is for an optional named {}", typeName);
Expand Down Expand Up @@ -1379,30 +1377,28 @@ protected static String typeReferenceNameForParameterizedType(Type type)

}

if(type instanceof ParameterizedType)
{
ParameterizedType pType = (ParameterizedType) type;
Class<?> genericType = (Class<?>)pType.getActualTypeArguments()[0];
Class<?> rawType = (Class<?>)pType.getRawType();
Class<?> erasedType = (Class<?>) HandlerGenerator.extractErasedType(genericType);

if(!(pType.getRawType() instanceof ParameterizedType))
{
return Character.toLowerCase(rawType.getSimpleName().charAt(0)) + rawType.getSimpleName().substring(1) + genericType.getSimpleName();
}


}
// if(type instanceof ParameterizedType)
// {
// ParameterizedType pType = (ParameterizedType) type;
// Class<?> genericType = (Class<?>)pType.getActualTypeArguments()[0];
// Class<?> rawType = (Class<?>)pType.getRawType();
// Class<?> erasedType = (Class<?>) HandlerGenerator.extractErasedType(genericType);
//
// if(!(pType.getRawType() instanceof ParameterizedType))
// {
// return Character.toLowerCase(rawType.getSimpleName().charAt(0)) + rawType.getSimpleName().substring(1) + genericType.getSimpleName();
// }
//
//
// }

return typeName;
}

protected static String typeReferenceNameForType(Type type)
{
String typeName = type.getTypeName();



String typeName = type.getTypeName();

String[] erasedParts = typeName.split("\\.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,9 @@ public static TypeHandler forType(Type type, Boolean isBeanParam)
boolean isArray = type.getTypeName().contains("java.util.List");
boolean isSet = type.getTypeName().contains("java.util.Set");
boolean isMap = type.getTypeName().contains("java.util.Map");
boolean isParameterized = type instanceof ParameterizedType;
// boolean isParameterized = type instanceof ParameterizedType;

if (!isOptional && !isArray && !isSet && !isMap && !isParameterized)
if (!isOptional && !isArray && !isSet && !isMap )
{
try
{
Expand Down

0 comments on commit 8ff44d1

Please sign in to comment.