Topic: General Level: All
Welcome to the world of cutting-edge technology! Every week, we bring you the latest and most incredible advancements in the tech industry that are sure to leave you feeling inspired and empowered.
Stay ahead of the game and be the first to know about the newest innovations shaping our world. Discover new ways to improve your daily life, become more efficient, and enjoy new experiences.
This week, we've got some exciting news to share with you!
Java compiler generates class file bytecodes that are executed by the JVM into a binary compilation for platform execution.
Entering GraalVM which produces native images during compilation that are platform native executables. These images are produced by AOT compilation of reachable code and reflective accesses are explicitly specified.
NativeImage analyzer capitalizes on the native executables to regenerate the source code and establish comprehension of how native executables are executed from the source-compiled images, paving the way for optimization and space for improvement.
Invoking intermediate operator, filter() on an Optional return the Optional if the predicate is satisfied, else an empty Optional. (same is the case if the predicate test is true given the input Optional is empty)
From the extract, where o being an Optional
"
var p = o.filter(v -> v == null);
The Predicate shown above returns true only if the argument value is null. In other words, anytime this Predicate is used in a filter operation on an Optional, the result must be an empty Optional. If the original Optional was not empty, the test fails, resulting in an empty result. If the original Optional was actually already empty, the test is never applied and the filter simply returns the original, unchanged—and still empty—Optional.
"
Consequently, the Optional ifPresent would consume the resultant Optional from the filter applied over the Predicate test
Subtask exception/interruption propagation helps in attaining a short-circuited behavior on the execution of tasks submitted by the thread on executor service, such that on failure or success terminating the other subtasks as the resultant would still be an error, thus optimizing resource utilization.
The subtasks are in the scope of the thread that it created, making it feasible for intertask operations
Jakarta Security as part of JakartaEE10 introduced a new authentication standard OpenID Connect with the annotation OpenIdAuthenticationMechanismDefinition.
The OpenID Connect (OIDC) authentication protocol implementation is provided by one of the vendors ie., Auth0 for securing the endpoints via OIDC to servlets.
1. Setup an Auth0 OIDC application and create an application with URL and callback URL
2. Retrieve the domain, client ID, and client secret from the Auth0 dashboard.
3. Configure the domain, client ID, and client secret on the Jakarta EE 10 OIDC annotation.
4. Enable roles and add them to the Auth0-created user.
5. Specify the role in the servlet on SecurityServlet with HttpConstraints on the roles allowed
6. Users without authentication are redirected to Auth0 for login, on success the redirection to the callback URL happens with the authentication code.
7. Jakarta EE security intercepts the redirect and exchanges the code for the authentication token before invoking the callback URL.
8. Authentication is performed based on the token returned and the resource is loaded if the ServletSecurity validates the role successfully.
JSON Web Token (JWT) validates the token without an OIDC callback redirection.
That can be secured via a filter interface with accessToken verified and sent in the request header
To retain the type of response returned from jakarta.ws.rs.core.Response to avoid type erasure at the runtime it is necessary to wrap the Response inside a GenericEntity as sent in the response body of the REST call.
REST request validations can be applied to the POJO/Beans or even to the Entity object with the help of Bean Validation Valid annotation against the type of the bean as a method type on the REST method.
The validation API has a broad range of annotations providing fine-grained support for all possible data constraints with a custom error message on the violation.
Bad request 400 will be returned from the Response body if the constraints are met, however, to have meaningful error responses we have to specify an ExceptionMapper implementation overriding the toResponse method that takes ConstraintViolationExceptions we can then parse through the constraint violation breached by the bean under test and return it in the response entity.
Low latency garbage collector ZGC high-level architecture of concurrent processing, colored pointers, load barriers, regionalized memory management, compacting, relocating, NUMA aware for achieving sub-millisecond pause times for object marking for GC, further reduction in the pause times are introduced in JDK 16
Project Amber furnished,
1. Records
2. Sealed classes
3. Pattern Matching
4. Incorporating sealed classes with pattern matching enabled simplified switch expressions
5. Records patterns with pattern matching for direct member variable access
A typical try-and-catch clause can be remodelled semantically such that for the Future type, the possible outcomes like success, failure, timeout, and interruption are handled by creating a sealed interface on these possible outcomes extending the same and switching via pattern matching to retrieve the results thereby accounting for all possible flow cases.
Custom JSON schema can be constructed by using a sealed interface housing in records with immutable Java-type variables and implementing the sealed interface.
Further, the sealed types can be pattern matched and extracted from the type variables as pattern variables and can be used successively in the pattern expression evaluation.
With such a rich set of features from Project Amber, we can code toward data-modelled business behavior synergizing OOP and DOP
Persisting a complete JSON document into a DB column can be implemented by defining UserType and specifying the following interface method mappings,
1. getSqlType -> returning JSON SqlTypes
2. returnedClass -> returning the POJO of JSON schema
3. nullSafeGet -> to get the JSON attribute value from the resultset into JSON POJO
4. nullSafeSet -> takes JSON POJO and with the help PreparedStatement updates or inserts the JSON document into the DB
5. deepCopy -> provides a copy of the JSON POJO that can be implemented by serialization and deserialization
Starting from Hibernate 6,
This mapping can be relatively straightforward by specifying,
1. Annotation JdbcTypeCode with SqlTypes as JSON onto the JSON POJO on the entity class
2. And if you wanted to provide a custom UserType mapping implementation Hibernate uses generics and accesses the fields of the resultset by their index and the identical implementations of UserTypes as specified above apply.
3. Post definitions Type annotate the entity reference to the JSON POJO type
For Hibernate 4 and 5,
1. The UserType implementation sqlTypes takes an int array specifying JAVA_OBJECT
2. returnedClass specifying the JSON POJO
3. nullSafeGet -> JSON Object mapper for conversion
4. nullSafeSet -> mapping the value to the JSON column with PreparedStatement on insert and update
5. deepCopy -> providing the same implementation as above
6. Register the UserType TypeDef annotation in the package-info.java file
JSON attribute query from Hibernate 5 to 6.1, uses a native query to fetch the JSON attribute from the column
From Hibernate 6.2, JPQL enabled support for JSON columns enabling access to the JSON attributes
Creating a combination of multiple columns into a single database element via type attribute and in turn, using it in ORM is possible via Struct annotation and Embeddable annotation onto the class that defines the composition. The class composition can also be a record type defining both the annotations. Such a class can be used in an entity definition as simply as using Embedded annotation, further when writing a JPQL the elements of embedded can be accessed via the dot operator.
Tracing the cause of an application error can be difficult, it involves a process of deliberately navigating around the scenario that manifested the error.
Modes to approach an issue,
1. All issues raise due to logical deviation or inconsistency
2. Getting stuck on the investigation is temporary
3. Establish an investigation time-bound after which seeking help could open new perspectives on the issue at hand
4. Prioritize the bug
5. Collect all possible logs, flows, and sequences involved in the bug incarnation
6. Replicate the issue in staging or localized environment to identify the root cause.
7. Leverage the Print statements, logs, and IDE debugger tools for determining the issue
8. If the issue is production specific and occurs only in concurrent, load-balanced conditions then formulate possible assumptions and iteratively add logs around the presumption and push to production to monitor and finalize the theory.
Being patient and persistent are surmounting virtues in debugging the root cause of an issue. A few of these below might help,
1. Take a walk and reorient your mind to gain a new perspective
2. Articulate the issue
3. Use sufficient logs
4. Retrace code flow
5. Get help and invite for discussion to gain a third-person view
Disclaimer:
This is a personal blog. Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in a professional or personal capacity, unless explicitly stated. Any views or opinions are not intended to malign any religion, ethnic group, club, organization, company, or individual. All content provided on this blog is for informational purposes only. The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of this information.
Downloadable Files and ImagesAny downloadable file, including but not limited to pdfs, docs, jpegs, pngs, is provided at the user’s own risk. The owner will not be liable for any losses, injuries, or damages resulting from a corrupted or damaged file.- Comments are welcome. However, the blog owner reserves the right to edit or delete any comments submitted to this blog without notice due to :
- Comments deemed to be spam or questionable spam.
- Comments including profanity.
- Comments containing language or concepts that could be deemed offensive.
- Comments containing hate speech, credible threats, or direct attacks on an individual or group.
Comments
Post a Comment