Skip to content

Commit e43ceee

Browse files
committed
Merge remote-tracking branch 'upstream/6.2.x' into 6.2.x
2 parents a7f00c7 + 333f0ab commit e43ceee

File tree

7 files changed

+57
-20
lines changed

7 files changed

+57
-20
lines changed

build.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ buildscript {
1010
classpath "com.bmuschko:gradle-nexus-plugin:$gradleNexusPluginVersion"
1111
classpath "javax.xml.bind:jaxb-api:$jaxbApiVersion"
1212
classpath "com.sun.xml.bind:jaxb-impl:$jaxbImplVersion"
13-
classpath "org.codehaus.groovy.modules.http-builder:http-builder:0.7.2"
1413
}
1514
}
1615

17-
import static groovyx.net.http.ContentType.*
18-
1916
apply plugin: 'idea'
2017

2118
ext {

grails-bootstrap/src/main/groovy/org/grails/exceptions/reporting/CodeSnippetPrinter.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ interface CodeSnippetPrinter {
2727
* Attempts to present a preview code snippet of the code that went wrong
2828
*
2929
* @param exception The exception
30+
* @param optional attributes for formatting
3031
* @return The code snippet or nothing if it can't be previewed
3132
*/
33+
String prettyPrintCodeSnippet(Throwable exception, Map attrs)
34+
35+
@Deprecated
3236
String prettyPrintCodeSnippet(Throwable exception)
3337
}

grails-bootstrap/src/main/groovy/org/grails/exceptions/reporting/DefaultStackTracePrinter.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ import org.codehaus.groovy.control.MultipleCompilationErrorsException
2323
*/
2424
class DefaultStackTracePrinter implements StackTracePrinter {
2525

26+
@Deprecated
2627
String prettyPrint(Throwable t) {
28+
prettyPrint(t, [:])
29+
}
30+
31+
@Override
32+
String prettyPrint(Throwable t, Map attrs) {
2733
if (t == null) return ''
2834
if (!t.stackTrace) return 'No stack trace available'
2935
final sw = new StringWriter()

grails-bootstrap/src/main/groovy/org/grails/exceptions/reporting/StackTracePrinter.groovy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,16 @@ interface StackTracePrinter {
2929
* @param throwable The throwable
3030
* @return The result
3131
*/
32+
@Deprecated
3233
String prettyPrint(Throwable throwable)
34+
35+
/**
36+
* Pretty print the given stack trace and return the result
37+
*
38+
* @param throwable The throwable
39+
* @param optional attributes for formatting
40+
* @return The result
41+
*/
42+
String prettyPrint(Throwable throwable, Map attrs)
43+
3344
}

grails-core/src/main/groovy/grails/beans/util/LazyBeanMap.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class LazyBeanMap implements Map<String,Object>{
117117
Collection<Object> values() {
118118
if(!cpf) return []
119119
else {
120-
keySet().collect() { String property -> cpf.getPropertyValue(property) }
120+
keySet().collect() { String property -> ((ClassPropertyFetcher) /*Cast needed after upgrade to Groovy 3.0.22, 4.0.22*/ cpf).getPropertyValue(property) }
121121
}
122122
}
123123

@@ -126,7 +126,7 @@ class LazyBeanMap implements Map<String,Object>{
126126
if(!cpf) return [] as Set<Map.Entry<String, Object>>
127127
else {
128128
return new HashSet<Map.Entry<String, Object>>(
129-
keySet().collect() { String property -> new AbstractMap.SimpleEntry<String, Object>(property, cpf.getPropertyValue(property)) }
129+
keySet().collect() { String property -> new AbstractMap.SimpleEntry<String, Object>(property, ((ClassPropertyFetcher) /*Cast needed after upgrade to Groovy 3.0.22, 4.0.22*/ cpf).getPropertyValue(property)) }
130130
)
131131
}
132132
}

grails-core/src/main/groovy/org/grails/core/exceptions/DefaultErrorsPrinter.groovy

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ class DefaultErrorsPrinter extends DefaultStackTracePrinter implements CodeSnipp
4747
res == null ? te.className : res.getFilename()
4848
}
4949

50+
@Deprecated
5051
String prettyPrintCodeSnippet(Throwable exception) {
52+
prettyPrintCodeSnippet(exception, [:])
53+
}
54+
55+
String prettyPrintCodeSnippet(Throwable exception, Map attrs) {
5156
if (exception == null) {
5257
return ''
5358
}
@@ -86,7 +91,7 @@ class DefaultErrorsPrinter extends DefaultStackTracePrinter implements CodeSnipp
8691
if (lineNumbersShown[res.filename].contains(lineNumber)) continue // don't repeat the same lines twice
8792

8893
lineNumbersShown[res.filename] << lineNumber
89-
pw.print formatCodeSnippetStart(res, lineNumber)
94+
pw.print formatCodeSnippetStart(res, lineNumber, attrs)
9095
def input = null
9196
try {
9297
input = res.inputStream
@@ -101,10 +106,10 @@ class DefaultErrorsPrinter extends DefaultStackTracePrinter implements CodeSnipp
101106
if (currentLineNumber in range) {
102107
boolean isErrorLine = currentLineNumber == lineNumber
103108
if (isErrorLine) {
104-
pw.print formatCodeSnippetErrorLine(currentLineNumber, currentLine)
109+
pw.print formatCodeSnippetErrorLine(currentLineNumber, currentLine, attrs)
105110
}
106111
else {
107-
pw.print formatCodeSnippetLine(currentLineNumber, currentLine)
112+
pw.print formatCodeSnippetLine(currentLineNumber, currentLine, attrs)
108113
}
109114
}
110115
else if (currentLineNumber > last) {
@@ -198,18 +203,32 @@ class DefaultErrorsPrinter extends DefaultStackTracePrinter implements CodeSnipp
198203
""
199204
}
200205

206+
@Deprecated
201207
String formatCodeSnippetStart(Resource resource, int lineNumber) {
208+
formatCodeSnippetStart(resource, lineNumber, [:])
209+
}
210+
211+
String formatCodeSnippetStart(Resource resource, int lineNumber, Map attrs) {
202212
"""Around line $lineNumber of $resource.filename
203213
"""
204-
205214
}
206215

216+
@Deprecated
207217
protected String formatCodeSnippetLine(int currentLineNumber, currentLine) {
218+
formatCodeSnippetLine(currentLineNumber, currentLine, [:])
219+
}
220+
221+
protected String formatCodeSnippetLine(int currentLineNumber, currentLine, Map attrs) {
208222
"""${currentLineNumber}: ${currentLine}
209223
"""
210224
}
211225

226+
@Deprecated
212227
protected String formatCodeSnippetErrorLine(int currentLineNumber, currentLine) {
228+
formatCodeSnippetErrorLine(currentLineNumber, currentLine, [:])
229+
}
230+
231+
protected String formatCodeSnippetErrorLine(int currentLineNumber, currentLine, Map attrs) {
213232
"""${currentLineNumber}: ${currentLine}
214233
"""
215234
}

grails-web-common/src/main/groovy/org/grails/web/errors/ErrorsViewStackTracePrinter.groovy

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ class ErrorsViewStackTracePrinter extends DefaultErrorsPrinter {
3838
}
3939

4040
@Override
41-
String prettyPrint(Throwable t) {
41+
String prettyPrint(Throwable t, Map attrs) {
4242
if (t instanceof GrailsWrappedRuntimeException) {
4343
t = t.cause
4444
}
45-
return super.prettyPrint(t)
45+
return super.prettyPrint(t, attrs)
4646
}
4747

4848
@Override
49-
String prettyPrintCodeSnippet(Throwable t) {
49+
String prettyPrintCodeSnippet(Throwable t, Map attrs) {
5050
if (t instanceof GrailsWrappedRuntimeException) {
5151
t = t.cause
5252
}
53-
return super.prettyPrintCodeSnippet(t)
53+
return super.prettyPrintCodeSnippet(t, attrs)
5454
}
5555

5656
@Override
57-
String formatCodeSnippetStart(Resource resource, int lineNumber) {
57+
String formatCodeSnippetStart(Resource resource, int lineNumber, Map attrs) {
5858
String path = resource.filename
5959
// try calc better path
6060
try {
@@ -67,8 +67,8 @@ class ErrorsViewStackTracePrinter extends DefaultErrorsPrinter {
6767
path = resource.filename
6868
}
6969
"""\
70-
<h2>Around line ${lineNumber} of <span class="filename">${path}</span></h2>
71-
<pre class="snippet">"""
70+
<h2>Around line ${lineNumber} of <span class="${attrs['filenameClass'] ?: 'filename'}">${path}</span></h2>
71+
<pre class="${attrs['snippetClass'] ?: 'snippet'}">"""
7272
}
7373

7474
@Override
@@ -77,13 +77,13 @@ class ErrorsViewStackTracePrinter extends DefaultErrorsPrinter {
7777
}
7878

7979
@Override
80-
protected String formatCodeSnippetLine(int currentLineNumber, Object currentLine) {
81-
"""<code class="line"><span class="lineNumber">${currentLineNumber}:</span>${currentLine.encodeAsHTML()}</code>"""
80+
protected String formatCodeSnippetLine(int currentLineNumber, Object currentLine, Map attrs) {
81+
"""<code class="${attrs['lineClass'] ?: 'line'}"><span class="${attrs['lineNumberClass'] ?: 'lineNumber'}">${currentLineNumber}:</span>${currentLine.encodeAsHTML()}</code>"""
8282
}
8383

8484
@Override
85-
protected String formatCodeSnippetErrorLine(int currentLineNumber, Object currentLine) {
86-
"""<code class="line error"><span class="lineNumber">${currentLineNumber}:</span>${currentLine.encodeAsHTML()}</code>"""
85+
protected String formatCodeSnippetErrorLine(int currentLineNumber, Object currentLine, Map attrs) {
86+
"""<code class="${attrs['lineErrorClass'] ?: 'line error'}"><span class="${attrs['lineNumberClass'] ?: 'lineNumber'}">${currentLineNumber}:</span>${currentLine.encodeAsHTML()}</code>"""
8787
}
8888

8989
@Override

0 commit comments

Comments
 (0)